Package org.linkki.util
Class BeanUtils
java.lang.Object
org.linkki.util.BeanUtils
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic BeanInfogetBeanInfo(Class<?> clazz) Returns the bean info for the given class.static FieldgetDeclaredField(Class<?> clazz, String name) Returns the class' declared field with the given name.static FieldReturns the class' field with the given name.static MethodReturns the method with the given name and parameter types.Returns an optional containing the class' method matching the given predicate (empty optional if none matches).getMethods(Class<?> clazz, Predicate<Method> predicate) Returns the class' methods matching the given predicate.static StringgetPropertyName(Method method) Returns the property name from the given method:String getFoo()-> "foo"boolean isBar()-> "bar"void fooBar()-> "fooBar"static StringgetPropertyName(Type returnType, String methodName) Returns the property name from the given method name:getFoo-> "foo"isBar-> "bar"fooBar-> "fooBar"static ObjectgetValueFromField(Object object, Field field) Returns the object's value for the field with the given name.static ObjectgetValueFromField(Object object, String name) Returns the object's value for the field with the given name.
-
Field Details
-
GET_PREFIX
- See Also:
-
SET_PREFIX
- See Also:
-
IS_PREFIX
- See Also:
-
-
Method Details
-
getBeanInfo
Returns the bean info for the given class. -
getMethod
Returns the method with the given name and parameter types.- See Also:
-
getMethod
Returns an optional containing the class' method matching the given predicate (empty optional if none matches). If you expect more than one match,getMethods(Class, Predicate)might be what you're looking for.- Throws:
IllegalStateException- If more than one method matches the predicate.
-
getMethods
Returns the class' methods matching the given predicate. -
getDeclaredField
Returns the class' declared field with the given name. Declared field means that the field is declared in the given class, any super classes are not searched.- See Also:
-
getField
Returns the class' field with the given name. In contrast togetDeclaredField(Class, String)this method searches the type's hierarchy (if the class extends a super class)- Throws:
RuntimeException- wrapping a NoSuchFieldException if no such field exists.- See Also:
-
getValueFromField
Returns the object's value for the field with the given name.- See Also:
-
getValueFromField
Returns the object's value for the field with the given name.- See Also:
-
getPropertyName
Returns the property name from the given method:String getFoo()-> "foo"boolean isBar()-> "bar"void fooBar()-> "fooBar"
-
getPropertyName
Returns the property name from the given method name:getFoo-> "foo"isBar-> "bar"fooBar-> "fooBar"
-