List of usage examples for org.springframework.data.repository.util ClassUtils hasProperty
public static boolean hasProperty(Class<?> type, String property)
From source file:com.frank.search.solr.core.ResultHelper.java
private static Object getMappedId(Object o) { if (ClassUtils.hasProperty(o.getClass(), "id")) { try {/*from w ww.java2 s .c o m*/ return FieldUtils.readDeclaredField(o, "id", true); } catch (IllegalAccessException e) { throw new MappingException("Id property could not be accessed!", e); } } for (java.lang.reflect.Field field : o.getClass().getDeclaredFields()) { Annotation annotation = AnnotationUtils.getAnnotation(field, Id.class); if (annotation != null) { try { return FieldUtils.readField(field, o, true); } catch (IllegalArgumentException e) { throw new MappingException("Id property could not be accessed!", e); } catch (IllegalAccessException e) { throw new MappingException("Id property could not be accessed!", e); } } } throw new MappingException("Id property could not be found!"); }