Class AnyBeanReader
java.lang.Object
org.klojang.invoke.AnyBeanReader
A dynamic bean reader class for arbitrary types of beans. This class uses the
java.lang.invoke package instead of reflection to read bean properties.
Yet it still uses reflection to identify the getter methods of the bean class.
Therefore, if you use this class from within a Java module you must open the
module to the naturalis-common module.- Author:
- Ayco Holleman
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a newAnyBeanReader.AnyBeanReader(boolean strictNaming) Creates a newAnyBeanReader. -
Method Summary
-
Constructor Details
-
AnyBeanReader
public AnyBeanReader()Creates a newAnyBeanReader. JavaBeans naming conventions will be applied regarding which methods qualify as getters. -
AnyBeanReader
public AnyBeanReader(boolean strictNaming) Creates a newAnyBeanReader.- Parameters:
strictNaming- iffalse, all methods with a zero-length parameter list and a non-voidreturn type, exceptgetClass(),hashCode()andtoString(), will be regarded as getters. Otherwise JavaBeans naming conventions will be applied regarding which methods qualify as getters. By way of exception, methods returning aBooleanare allowed to have a name starting with "is" (just like methods returning aboolean). ThestrictNamingparameter is quietly ignored forrecordclasses. Records are always processed as thoughstrictNamingwerefalse.
-
-
Method Details
-
read
Returns the value of the specified property on the specified bean. If the property does not exist aNoSuchPropertyExceptionis thrown.- Type Parameters:
U- the return type- Parameters:
bean- the bean instanceproperty- the property- Returns:
- its value
- Throws:
NoSuchPropertyException- if the specified property does not exist
-