Answers for "how to check if object exists in model class"

4

javascript check if object property exists

var person = {'first_name': 'bill','age':20};

if ( person.hasOwnProperty('first_name') ) {
    //person has a first_name property
}
Posted by: Guest on July-23-2019
0

java check if property exists in class

public boolean doesObjectContainField(Object object, String fieldName) {
    return Arrays.stream(object.getClass().getFields())
            .anyMatch(f -> f.getName().equals(fieldName));
}
Posted by: Guest on May-01-2021

Code answers related to "how to check if object exists in model class"

Code answers related to "Javascript"

Browse Popular Code Answers by Language