-
- Type Parameters:
V- type of theproperty value.
- All Known Subinterfaces:
BeanPropertyMetadata<V>
- All Known Implementing Classes:
AbstractPropertyMetadata,BeanPropertyMetadataSimple,BeanPropertyMetadataType,PropertyMetadataNone,PropertyMetadataType
public interface PropertyMetadata<V>Metadata of aProperty. Implementations ofPropertyMetadataare supposed to be immutable. It is discouraged and may have odd effects if thePropertyMetadatachanges after it has been passed to the constructor of a property.- Since:
- 1.0.0
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description Map<String,Object>asMap()default <T> Tget(Class<T> type)ATTENTION: This is a convenient method forget(String, Class)whereClass.getName()is used as key.Objectget(String key)default <T> Tget(String key, Class<T> type)Supplier<? extends V>getExpression()intgetKeyCount()Iterable<String>getKeys()default Marshalling<V>getMarshalling()Validator<? super V>getValidator()TypegetValueType()default booleanhasKeys()default booleanisTransient()PropertyMetadata<V>withValidator(Validator<? super V> validator)
-
-
-
Method Detail
-
get
Object get(String key)
- Parameters:
key- thekeyof the requested metadata.- Returns:
- the value of the metadata for the given
key. Will benullif no metadata exists for the givenkey. - See Also:
get(String, Class)
-
get
default <T> T get(Class<T> type)
ATTENTION: This is a convenient method forget(String, Class)whereClass.getName()is used as key. Be aware that this can only work for final classes,Annotations or if the producer of thisPropertyMetadataprovides the metadata under thetypeyou are expecting as API. Also it is discouraged to use this method for generic types such asStringorLongas values of such type can be anything and should have a semantic key.- Type Parameters:
T- type of the metadata.- Parameters:
type-Classreflecting the type of the requested metadata value.- Returns:
- the value of the metadata for the given
key. Will benullif no metadata exists for the givenkey. - See Also:
get(String, Class)
-
getKeys
Iterable<String> getKeys()
- Returns:
- the
Iterableof allmetadata keys.
-
hasKeys
default boolean hasKeys()
-
getValueType
Type getValueType()
- Returns:
- the optional
Typeof theproperty value. May benull. - See Also:
ReadableTypedValue.getValueClass()
-
getMarshalling
default Marshalling<V> getMarshalling()
- Returns:
- the optional custom
Marshalling. Ifnullthe default marshalling of thePropertyis used. Overriding also allows to extend or replace the property value with more complex data from this metadata - e.g. to reuse aBeanto represent a query to find instances of thatBean.
-
isTransient
default boolean isTransient()
- Returns:
trueif transient (e.g. computed and therefore not to be marshalled),falseotherwise.- See Also:
ReadableProperty.isTransient()
-
withValidator
PropertyMetadata<V> withValidator(Validator<? super V> validator)
- Parameters:
validator- the newValidator.- Returns:
- a new instance of
PropertyMetadatawith the givenValidatorused forgetValidator().
-
-