-
- 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 ofPropertyMetadata
are supposed to be immutable. It is discouraged and may have odd effects if thePropertyMetadata
changes 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> T
get(Class<T> type)
ATTENTION: This is a convenient method forget(String, Class)
whereClass.getName()
is used as key.Object
get(String key)
default <T> T
get(String key, Class<T> type)
Supplier<? extends V>
getExpression()
int
getKeyCount()
Iterable<String>
getKeys()
default Marshalling<V>
getMarshalling()
Validator<? super V>
getValidator()
Type
getValueType()
default boolean
hasKeys()
default boolean
isTransient()
PropertyMetadata<V>
withValidator(Validator<? super V> validator)
-
-
-
Method Detail
-
get
Object get(String key)
- Parameters:
key
- thekey
of the requested metadata.- Returns:
- the value of the metadata for the given
key
. Will benull
if 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,Annotation
s or if the producer of thisPropertyMetadata
provides the metadata under thetype
you are expecting as API. Also it is discouraged to use this method for generic types such asString
orLong
as values of such type can be anything and should have a semantic key.- Type Parameters:
T
- type of the metadata.- Parameters:
type
-Class
reflecting the type of the requested metadata value.- Returns:
- the value of the metadata for the given
key
. Will benull
if no metadata exists for the givenkey
. - See Also:
get(String, Class)
-
getKeys
Iterable<String> getKeys()
- Returns:
- the
Iterable
of allmetadata keys
.
-
hasKeys
default boolean hasKeys()
-
getValueType
Type getValueType()
- Returns:
- the optional
Type
of theproperty value
. May benull
. - See Also:
ReadableTypedValue.getValueClass()
-
getMarshalling
default Marshalling<V> getMarshalling()
- Returns:
- the optional custom
Marshalling
. Ifnull
the default marshalling of theProperty
is used. Overriding also allows to extend or replace the property value with more complex data from this metadata - e.g. to reuse aBean
to represent a query to find instances of thatBean
.
-
isTransient
default boolean isTransient()
- Returns:
true
if transient (e.g. computed and therefore not to be marshalled),false
otherwise.- See Also:
ReadableProperty.isTransient()
-
withValidator
PropertyMetadata<V> withValidator(Validator<? super V> validator)
- Parameters:
validator
- the newValidator
.- Returns:
- a new instance of
PropertyMetadata
with the givenValidator
used forgetValidator()
.
-
-