Class BeanReaderBuilder<T>

java.lang.Object
org.klojang.invoke.BeanReaderBuilder<T>
Type Parameters:
T - the type of the objects to be read by the BeanReader.

public final class BeanReaderBuilder<T> extends Object
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 Details

    • withInt

      public BeanReaderBuilder<T> withInt(String... properties)
      Registers the specified names as int properties on the bean class.
      Parameters:
      properties - the property names
      Returns:
      this instance
    • withString

      public BeanReaderBuilder<T> withString(String... properties)
      Registers the specified names as String properties on the bean class.
      Parameters:
      properties - the property names
      Returns:
      this instance
    • with

      public BeanReaderBuilder<T> with(Class<?> type, String... properties)
      Registers the specified names as properties of the specified type. If the bean class is a record type, there is no difference between calling this method and calling withGetter().
      Parameters:
      type - the type of the properties
      properties - the property names
      Returns:
      this instance
    • withGetter

      public BeanReaderBuilder<T> withGetter(Class<?> returnType, String... names)
      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 a record type, there is no difference between calling this method and calling with().
      Parameters:
      returnType - the return type of the specified getters
      names - the names of the getters
      Returns:
      this instance
    • withTransformer

      public BeanReaderBuilder<T> withTransformer(BeanValueTransformer<T> transformer)
    • build

      public BeanReader<T> build() throws NoPublicGettersException
      Returns a new BeanReader for instances of type T.
      Returns:
      a new BeanReader for instances of type T
      Throws:
      NoPublicGettersException - if no properties have been added yet via the various with*** methods