java check if property exists in class

64

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));
}

Comments

Submit
0 Comments