public static boolean propertyExists ( Class < ? > clazz , String property , ElementType elementType ) { if ( ElementType . FIELD . equals ( elementType ) ) { return getDeclaredField ( clazz , property ) != null ; } else { String capitalizedPropertyName = capitalize ( property ) ; Method method = getMethod ( clazz , PROPERTY_ACCESSOR_PREFIX_GET + capitalizedPropertyName ) ; if ( method != null && method . getReturnType ( ) != void . class ) { return true ; } method = getMethod ( clazz , PROPERTY_ACCESSOR_PREFIX_IS + capitalizedPropertyName ) ; if ( method != null && method . getReturnType ( ) == boolean . class ) { return true ; } } return false ; }
Whether the specified JavaBeans property exists on the given type or not .