java.lang.Object
org.klojang.templates.AccessorRegistry.Builder
- Enclosing class:
AccessorRegistry
A builder class for
AccessorRegistry
instances.- Author:
- Ayco Holleman
-
Method Summary
Modifier and TypeMethodDescriptionfreeze()
Returns anAccessorRegistry
with the configured accessors.nullEqualsUndefined
(boolean b) Determines whethernull
values should be treated just likeAccessor.UNDEFINED
.Sets theAccessor
to be used for objects of the specified type.register
(BeanReader<T> br) Use the specifiedBeanReader
to access objects of the type theBeanReader
can read.register
(BeanReader<T> br, NameMapper nameMapper) Use the specifiedBeanReader
to access objects of the type theBeanReader
can read.register
(BeanReader<T> beanReader, Template template) Use the specifiedBeanReader
to access objects of the type theBeanReader
can read.register
(BeanReader<T> beanReader, Template template, NameMapper nameMapper) Use the specifiedBeanReader
to access objects of the type theBeanReader
can read.Sets theAccessor
to be used for objects of the specified type, when inserted into the specified template.setDefaultNameMapper
(NameMapper nameMapper) Sets the defaultNameMapper
used to map template variables to bean properties and/or map keys.setNameMapper
(Template template, NameMapper nameMapper) Sets theNameMapper
to be used for the specified template.
-
Method Details
-
setDefaultNameMapper
Sets the defaultNameMapper
used to map template variables to bean properties and/or map keys. If no defaultNameMapper
is specified, template variables will be mapped as-is to bean properties and/or map keys.- Parameters:
nameMapper
- the name mapper- Returns:
- this
Builder
instance
-
nullEqualsUndefined
Determines whethernull
values should be treated just likeAccessor.UNDEFINED
. By default this is not the case.- Parameters:
b
- whethernull
values should be treated just likeAccessor.UNDEFINED
- Returns:
- this
Builder
instance - See Also:
-
setNameMapper
Sets theNameMapper
to be used for the specified template.- Parameters:
template
- the template for which to use the specified name mappernameMapper
- the name mapper- Returns:
- this
Builder
instance
-
register
Sets theAccessor
to be used for objects of the specified type.- Type Parameters:
T
- the type of the objects for which to use theAccessor
- Parameters:
type
- theClass
object corresponding to the typeaccessor
- theAccessor
- Returns:
- this
Builder
instance
-
register
public <T> AccessorRegistry.Builder register(Template template, Class<T> type, Accessor<T> accessor) Sets theAccessor
to be used for objects of the specified type, when inserted into the specified template.- Type Parameters:
T
- the type of the objects for which to use theAccessor
- Parameters:
template
- the template for which to use theAccessor
type
- theClass
object corresponding to the typeaccessor
- theAccessor
- Returns:
- this
Builder
instance
-
register
Use the specifiedBeanReader
to access objects of the type theBeanReader
can read. Use aBeanReaderBuilder
to obtain theBeanReader
if you prefer 100% reflection-free bean reading. SeeBeanReader.forClass(Class)
.- Type Parameters:
T
- the type of the beans- Parameters:
br
- theBeanReader
- Returns:
- this
Builder
instance
-
register
Use the specifiedBeanReader
to access objects of the type theBeanReader
can read. Use aBeanReaderBuilder
to obtain theBeanReader
if you prefer 100% reflection-free bean reading. SeeBeanReader.forClass(Class)
.- Type Parameters:
T
- the type of the beans- Parameters:
beanReader
- theBeanReader
template
- the template for which to use the accessor (may be a root template or a nested template)- Returns:
- this
Builder
instance
-
register
Use the specifiedBeanReader
to access objects of the type theBeanReader
can read. Use aBeanReaderBuilder
to obtain theBeanReader
if you prefer 100% reflection-free bean reading. SeeBeanReader.forClass(Class)
.- Type Parameters:
T
- the type of the beans- Parameters:
br
- theBeanReader
nameMapper
- theNameMapper
to be used to map template variables to bean properties- Returns:
- this
Builder
instance
-
register
public <T> AccessorRegistry.Builder register(BeanReader<T> beanReader, Template template, NameMapper nameMapper) Use the specifiedBeanReader
to access objects of the type theBeanReader
can read. Use aBeanReaderBuilder
to obtain theBeanReader
if you prefer 100% reflection-free bean reading. SeeBeanReader.forClass(Class)
.- Type Parameters:
T
- the type of the beans- Parameters:
beanReader
- theBeanReader
template
- the template for which to use the accessor (may be a root template or a nested template)nameMapper
- theNameMapper
to be used to map template variables to bean properties- Returns:
- this
Builder
instance
-
freeze
Returns anAccessorRegistry
with the configured accessors.- Returns:
- an
AccessorRegistry
with the configured accessors
-