public final class JavaBeanObjectPropertyBuilder<T> extends Object
JavaBeanObjectPropertyBuilder
can be used to create
JavaBeanObjectProperties
. To create
a JavaBeanObjectProperty
one first has to call create()
to generate a builder, set the required properties, and then one can
call build()
to generate the property.
Not all properties of a builder have to specified, there are several
combinations possible. As a minimum the name(java.lang.String)
of
the property and the bean(java.lang.Object)
have to be specified.
If the names of the getter and setter follow the conventions, this is sufficient.
Otherwise it is possible to specify an alternative name for the getter and setter
(getter(java.lang.String)
and setter(java.lang.String)
) or
the getter and setter Methods
directly (getter(java.lang.reflect.Method)
and setter(java.lang.reflect.Method)
).
All methods to change properties return a reference to this builder, to enable method chaining.
If you have to generate adapters for the same property of several instances
of the same class, you can reuse a JavaBeanObjectPropertyBuilder
.
by switching the Java Bean instance (with bean(java.lang.Object)
and
calling build()
.
JavaBeanObjectProperty
Constructor and Description |
---|
JavaBeanObjectPropertyBuilder() |
Modifier and Type | Method and Description |
---|---|
JavaBeanObjectPropertyBuilder |
bean(Object bean)
Set the Java Bean instance the adapter should connect to
|
JavaBeanObjectPropertyBuilder |
beanClass(Class<?> beanClass)
Set the Java Bean class in which the getter and setter should be searched.
|
JavaBeanObjectProperty<T> |
build()
Generate a new
JavaBeanObjectProperty with the current settings. |
static JavaBeanObjectPropertyBuilder |
create()
Create a new instance of
JavaBeanObjectPropertyBuilder |
JavaBeanObjectPropertyBuilder |
getter(Method getter)
Set the getter method directly.
|
JavaBeanObjectPropertyBuilder |
getter(String getter)
Set an alternative name for the getter.
|
JavaBeanObjectPropertyBuilder |
name(String name)
Set the name of the property
|
JavaBeanObjectPropertyBuilder |
setter(Method setter)
Set the setter method directly.
|
JavaBeanObjectPropertyBuilder |
setter(String setter)
Set an alternative name for the setter.
|
public static JavaBeanObjectPropertyBuilder create()
JavaBeanObjectPropertyBuilder
JavaBeanObjectPropertyBuilder
public JavaBeanObjectProperty<T> build() throws NoSuchMethodException
JavaBeanObjectProperty
with the current settings.JavaBeanObjectProperty
NoSuchMethodException
- if the settings were not sufficient to find
the getter and the setter of the Java Bean propertypublic JavaBeanObjectPropertyBuilder name(String name)
name
- the name of the propertypublic JavaBeanObjectPropertyBuilder bean(Object bean)
bean
- the Java Bean instancepublic JavaBeanObjectPropertyBuilder beanClass(Class<?> beanClass)
beanClass
- the Java Bean classpublic JavaBeanObjectPropertyBuilder getter(String getter)
getter
- the alternative name of the getterpublic JavaBeanObjectPropertyBuilder setter(String setter)
setter
- the alternative name of the setterpublic JavaBeanObjectPropertyBuilder getter(Method getter)
getter
- the getterpublic JavaBeanObjectPropertyBuilder setter(Method setter)
setter
- the setterSubmit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 2008, 2017, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.