Class ReflectivePropertyProvider
java.lang.Object
org.vaadin.miki.superfields.object.reflect.ReflectivePropertyProvider
- All Implemented Interfaces:
Serializable,PropertyProvider
Simple reflection-based definition provider.
It scans a given type for
private fields (including final) and corresponding setters and/or getters.
Delegates the scanning to ReflectTools.extractFieldsWithMethods(Class, boolean).
Superclasses are by default included, unless DoNotScanSuperclasses is used on the type.
All fields are included in the results, except fields annotated with Ignore.
The declared field types are used, unless UseActualType is used, in which case the actual type of the field's value is used.
The results are cached, except when a type has UseActualType annotation on any of its fields.- Since:
- 2022-06-03
- Author:
- miki
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal voidaddMetadataProvider(MetadataProvider... providers) Adds givenMetadataProviders.getObjectPropertyDefinitions(Class<T> type, T instance) Builds a list of property definitions for a given object.booleanChecks whether a fake getter (i.e.booleanChecks whether a fake setter (i.e.voidsetUsingFakeGettersWhenNotPresent(boolean usingFakeGettersWhenNotPresent) Allows using a fake getter when there is no getter for a given property.voidsetUsingFakeSettersWhenNotPresent(boolean usingFakeSettersWhenNotPresent) Allows using a fake setter when there is no setter for a given property.withMetadataProvider(MetadataProvider... providers) ChainsaddMetadataProvider(MetadataProvider...)and returns itself.withUsingFakeGettersWhenNotPresent(boolean setting) ChainssetUsingFakeGettersWhenNotPresent(boolean)and returns itself.withUsingFakeSettersWhenNotPresent(boolean setting) ChainssetUsingFakeGettersWhenNotPresent(boolean)and returns itself.
-
Constructor Details
-
ReflectivePropertyProvider
public ReflectivePropertyProvider()
-
-
Method Details
-
getObjectPropertyDefinitions
Description copied from interface:PropertyProviderBuilds a list of property definitions for a given object.- Specified by:
getObjectPropertyDefinitionsin interfacePropertyProvider- Type Parameters:
T- Generic type to enforce bothtypeandinstanceare compatible.- Parameters:
type- Type of the object.instance- An instance of the object. Can benull.- Returns:
- A non-
nulllist ofPropertys that can be empty.
-
addMetadataProvider
Adds givenMetadataProviders. They will be called in order of adding.- Parameters:
providers- An array ofMetadataProviders to add.
-
withMetadataProvider
ChainsaddMetadataProvider(MetadataProvider...)and returns itself.- Parameters:
providers- An array ofMetadataProviders to add.- Returns:
- This.
- See Also:
-
isUsingFakeSettersWhenNotPresent
public boolean isUsingFakeSettersWhenNotPresent()Checks whether a fake setter (i.e. one that does nothing) is returned when there is no setter for a property.- Returns:
- When
true, a fake setter is used instead of anullvalue (default).
-
setUsingFakeSettersWhenNotPresent
public void setUsingFakeSettersWhenNotPresent(boolean usingFakeSettersWhenNotPresent) Allows using a fake setter when there is no setter for a given property. This allows setters to be called regardless of whether they exist or not.- Parameters:
usingFakeSettersWhenNotPresent- Whentrueand a setter for a property is missing, a fake one will be used instead ofnull.
-
withUsingFakeSettersWhenNotPresent
ChainssetUsingFakeGettersWhenNotPresent(boolean)and returns itself.- Parameters:
setting- Whether to fake setters.- Returns:
- This.
- See Also:
-
isUsingFakeGettersWhenNotPresent
public boolean isUsingFakeGettersWhenNotPresent()Checks whether a fake getter (i.e. one that always returnsnull) is returned when there is no getter for a property.- Returns:
- When
true, a fake getter is used instead of anullvalue (default).
-
setUsingFakeGettersWhenNotPresent
public void setUsingFakeGettersWhenNotPresent(boolean usingFakeGettersWhenNotPresent) Allows using a fake getter when there is no getter for a given property. This allows getters to be called regardless of whether they exist or not.- Parameters:
usingFakeGettersWhenNotPresent- Whentrueand a getter for a property is missing, a fake one will be used instead ofnull.
-
withUsingFakeGettersWhenNotPresent
ChainssetUsingFakeGettersWhenNotPresent(boolean)and returns itself.- Parameters:
setting- Whentrueand a getter for a property is missing, a fake one will be used instead ofnull.- Returns:
- This.
- See Also:
-