Class BeanReaderBuilder<T>
java.lang.Object
org.klojang.invoke.BeanReaderBuilder<T>
- Type Parameters:
T
- the type of the objects to be read by theBeanReader
.
A
Builder
class for BeanReader
instances. Use this class if the bean
class resides in a Java 9+ module that does not allow reflective access to its classes,
or if you need or prefer 100% reflection-free bean readers for other reasons. You
obtain a BeanReaderBuilder
instance through
BeanReader.forClass()
.-
Method Summary
Modifier and TypeMethodDescriptionbuild()
Returns a newBeanReader
for instances of typeT
.Registers the specified names as properties of the specified type.withGetter
(Class<?> returnType, String... names) Registers the specified method names as getters with the specified return type.Registers the specified names asint
properties on the bean class.withString
(String... properties) Registers the specified names asString
properties on the bean class.withTransformer
(BeanValueTransformer<T> transformer)
-
Method Details
-
withInt
Registers the specified names asint
properties on the bean class.- Parameters:
properties
- the property names- Returns:
- this instance
-
withString
Registers the specified names asString
properties on the bean class.- Parameters:
properties
- the property names- Returns:
- this instance
-
with
Registers the specified names as properties of the specified type. If the bean class is arecord
type, there is no difference between calling this method and callingwithGetter()
.- Parameters:
type
- the type of the propertiesproperties
- the property names- Returns:
- this instance
-
withGetter
Registers the specified method names as getters with the specified return type. You can use this method to register getter-type methods (zero parameters, non-void return type) with names that do not conform to the JavaBeans naming conventions. The provided names are supposed to be complete method names of public getters on the bean class. For example: "getLastName". If the bean class is arecord
type, there is no difference between calling this method and callingwith()
.- Parameters:
returnType
- the return type of the specified gettersnames
- the names of the getters- Returns:
- this instance
-
withTransformer
-
build
Returns a newBeanReader
for instances of typeT
.- Returns:
- a new
BeanReader
for instances of typeT
- Throws:
NoPublicGettersException
- if no properties have been added yet via the variouswith***
methods
-