public interface BeanAccess extends JsonSupport
Bean.PROPERTY_TYPE| Modifier and Type | Method and Description |
|---|---|
<V,PROPERTY extends WritableProperty<V>> |
addPropertyValidator(WritableProperty<?> property,
AbstractValidator<? super V> validator)
|
<V,PROPERTY extends WritableProperty<V>> |
addPropertyValidators(WritableProperty<?> property,
Collection<AbstractValidator<? super V>> validators)
|
default <V,PROPERTY extends WritableProperty<V>> |
createProperty(String name,
Class<PROPERTY> propertyType)
Creates and adds the specified
WritableProperty on the fly. |
<V,PROPERTY extends WritableProperty<V>> |
createProperty(String name,
GenericType<? extends V> valueType,
Class<PROPERTY> propertyType)
Creates and adds the specified
WritableProperty on the fly. |
default <V> WritableProperty<V> |
createProperty(String name,
GenericType<V> valueType)
Creates and adds the specified
WritableProperty on the fly. |
Iterable<String> |
getAliases() |
Class<? extends Bean> |
getBeanClass() |
Set<String> |
getDeclaredPropertyNames() |
default <V,PROPERTY extends WritableProperty<V>> |
getOrCreateProperty(String name,
Class<PROPERTY> propertyType)
|
default <V,PROPERTY extends WritableProperty<V>> |
getOrCreateProperty(String name,
GenericType<? extends V> valueType,
Class<PROPERTY> propertyType)
|
default <V> WritableProperty<V> |
getOrCreateProperty(String name,
GenericType<V> valueType)
|
String |
getPackageName() |
Iterable<WritableProperty<?>> |
getProperties() |
WritableProperty<?> |
getProperty(String name) |
String |
getPropertyNameForAlias(String alias)
An alias is an alternative for a
property name. |
Set<String> |
getPropertyNames() |
default Object |
getPropertyValue(String name) |
String |
getQualifiedName() |
default WritableProperty<?> |
getRequiredProperty(String name) |
String |
getSimpleName() |
boolean |
isDynamic() |
boolean |
isPrototype() |
boolean |
isReadOnly() |
boolean |
isVirtual() |
default void |
setPropertyValue(String name,
Object value) |
default <V> void |
setPropertyValue(String name,
V value,
GenericType<V> type)
|
default ValidationFailure |
validate() |
fromJson, toJsonIterable<WritableProperty<?>> getProperties()
Set<String> getPropertyNames()
immutable Set with the
names of the properties.Set<String> getDeclaredPropertyNames()
immutable Set with the
names of the properties declared by this
bean class. In other words a sub-set of getPropertyNames() is returned
that excludes the names of the inherited properties.Class.getDeclaredFields()String getPropertyNameForAlias(String alias)
property name. It
is defined by annotating the property method with Named and allows to support a property under a legacy
name after it has been renamed as well as to use a technical name containing special characters (e.g. "@" or ".")
for very specific cases.alias - the alias name.property name or null if no such alias is defined.WritableProperty<?> getProperty(String name)
name - the name of the requested property or a potential
alias of the property.WritableProperty or null if no such property exists.String getSimpleName()
simple name of the Bean. The last segment of the
getQualifiedName() (excluding the package name).getQualifiedName()String getQualifiedName()
qualified name of the bean interface. By default
derived from Class.getName() of the bean-interface. Will be overridden if a
Named annotation is present at the interface. If the Named.value() of the Named
annotation is unqualified (contains no dot) then the package of the
bean interface is appended. Further the name can be provided when
dynamic bean prototypes are created.
Again if an unqualified name is provided as argument, the package of the
bean interface is appended.String getPackageName()
package name of the bean class. The
qualified name excluding the simple name. Will be the
empty string for the default package (then getQualifiedName() is equal to getSimpleName()).getQualifiedName()default WritableProperty<?> getRequiredProperty(String name) throws PojoPropertyNotFoundException
name - the name of the requested property.WritableProperty.PojoPropertyNotFoundException - if the requested property does not exist.default ValidationFailure validate()
ValidationFailure or null if this Bean is valid according to this
ValueValidator.ValueValidator.validate(Object)default <V> WritableProperty<V> getOrCreateProperty(String name, GenericType<V> valueType)
Gets or creates the specified property.
If the property already exists also the type has to match the given type
or an exception will be thrown.V - the generic type of the property value.name - the property name.valueType - the property type.default <V,PROPERTY extends WritableProperty<V>> PROPERTY getOrCreateProperty(String name, Class<PROPERTY> propertyType)
Gets or creates the specified property. If the
property already exists it also has to match the given type or an exception will be thrown.V - the generic type of the property value.PROPERTY - the generic type of the property.name - the property name.propertyType - the Class reflecting the WritableProperty to create.default <V,PROPERTY extends WritableProperty<V>> PROPERTY getOrCreateProperty(String name, GenericType<? extends V> valueType, Class<PROPERTY> propertyType)
Gets or creates the specified property. If the
property already exists it also has to match the given type or an exception will be thrown.V - the generic type of the property value.PROPERTY - the generic type of the property.name - the property name.valueType - the property type.propertyType - the Class reflecting the WritableProperty to create.default Object getPropertyValue(String name)
name - the name of the property.value of the specified property.default void setPropertyValue(String name, Object value)
bean - the Bean instance.name - the name of the property.value - new value of the specified property.default <V> void setPropertyValue(String name, V value, GenericType<V> type)
property with the given name to
the specified value. If the property does not already exist, it will
dynamically be created.V - the generic type of the property value.name - the property name.value - new value of the specified property. Maybe null and in
such case a missing property will NOT be
created.type - the property type. May be null if the
property has to be created then the
type will be derived from value as fallback.default <V> WritableProperty<V> createProperty(String name, GenericType<V> valueType)
WritableProperty on the fly. Creating and adding new properties is only
possible for dynamic beans.V - the generic type of the property value.name - the property name.valueType - the property type.default <V,PROPERTY extends WritableProperty<V>> PROPERTY createProperty(String name, Class<PROPERTY> propertyType)
WritableProperty on the fly. Creating and adding new properties is only
possible for dynamic beans.V - the generic type of the property value.PROPERTY - the generic type of the property.name - the property name.propertyType - the Class reflecting the WritableProperty to create.<V,PROPERTY extends WritableProperty<V>> PROPERTY createProperty(String name, GenericType<? extends V> valueType, Class<PROPERTY> propertyType)
WritableProperty on the fly. Creating and adding new properties is only
possible for dynamic beans.V - the generic type of the property value.PROPERTY - the generic type of the property.name - the property name.valueType - propertyType - the Class reflecting the WritableProperty to create.<V,PROPERTY extends WritableProperty<V>> void addPropertyValidator(WritableProperty<?> property, AbstractValidator<? super V> validator)
property such that the provided validator is added. Therefore the Bean has to be a dynamic prototype that is not read-only.V - the generic type of the property value.PROPERTY - the generic type of the property.property - the property to update. Has to be owned by the owning Bean.validator - is the validator to add. The implementation tries its best to be
idempotent so adding the same validator again should have no effect.<V,PROPERTY extends WritableProperty<V>> void addPropertyValidators(WritableProperty<?> property, Collection<AbstractValidator<? super V>> validators)
property such that the provided validator is added. Therefore the Bean has to be a dynamic prototype that is not read-only.V - the generic type of the property value.PROPERTY - the generic type of the property.property - the property to update. Has to be owned by the owning Bean.validators - is the Collection with the validators to add. The
implementation tries its best to be idempotent so adding the same validator again should have no effect.boolean isReadOnly()
true if this BeanAccess belongs to a Bean that is read-only (immutable),
false otherwise.AbstractBeanFactory.getReadOnlyBean(Bean)boolean isDynamic()
true if this BeanAccess belongs to a dynamic Bean. Dynamic means that the
Bean is not strictly typed and allows to create
and add properties on the fly, false otherwise.BeanPrototypeBuilder.isDynamic(),
BeanPrototypeBuilder.getOrCreatePrototype(Class)boolean isPrototype()
true if this BeanAccess belongs to a prototype,
false otherwise (if it belongs to an instance).BeanFactory.createPrototype(Class),
AbstractBeanFactory.getPrototype(Bean),
BeanPrototypeBuilder.getOrCreatePrototype(Class),
BeanPrototypeBuilder.createPrototype(Class, String, Bean...)boolean isVirtual()
true if this BeanAccess belongs to a virtual Bean. Virtual means that the
prototype of the bean has been created via
BeanPrototypeBuilder.createPrototype(Class, String, Bean...) and represents a class (interface)
that does not exist as Java Class, false otherwise.BeanPrototypeBuilder.createPrototype(Class, String, Bean...)Copyright © 2001–2016 mmm-Team. All rights reserved.