- Type Parameters:
V
- type of theproperty value
.
- All Known Implementing Classes:
AbstractPropertyMetadata
public interface PropertyMetadata<V>
Metadata of a
Property
. Implementations of PropertyMetadata
are supposed to be immutable. It is
discouraged and may have odd effects if the PropertyMetadata
changes after it has been passed to the
constructor of a property.- Since:
- 1.0.0
-
Method Summary
Modifier and TypeMethodDescriptionasMap()
default <T> T
ATTENTION: This is a convenient method forget(String, Class)
whereClass.getName()
is used as key.default <T> T
int
getKeys()
default AttributeReadOnly
getLock()
default io.github.mmm.marshall.Marshalling<V>
default boolean
hasKeys()
default boolean
static <V> PropertyMetadata<V>
of
(AttributeReadOnly lock) static <V> PropertyMetadata<V>
of
(AttributeReadOnly lock, Validator<? super V> validator) static <V> PropertyMetadata<V>
of
(AttributeReadOnly lock, Validator<? super V> validator, Supplier<? extends V> expression) static <V> PropertyMetadata<V>
of
(AttributeReadOnly lock, Validator<? super V> validator, Supplier<? extends V> expression, Type valueType) static <V> PropertyMetadata<V>
of
(AttributeReadOnly lock, Validator<? super V> validator, Supplier<? extends V> expression, Type valueType, Map<String, Object> map) static <V> PropertyMetadata<V>
ofExpression
(Supplier<? extends V> expression) withExpression
(Supplier<? extends V> newExpression) withLock
(AttributeReadOnly newLock) withValidator
(Validator<? super V> newValidator)
-
Method Details
-
getValidator
-
getExpression
-
get
- 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
-
get
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:
-
getKeys
- Returns:
- the
Iterable
of allmetadata keys
.
-
getKeyCount
int getKeyCount() -
hasKeys
default boolean hasKeys() -
asMap
-
getValueType
Type getValueType()- Returns:
- the optional
Type
of theproperty value
. May benull
. - See Also:
-
ReadableTypedValue.getValueClass()
-
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:
-
withLock
- Parameters:
newLock
- the newlock
.- Returns:
- a new instance of
PropertyMetadata
with the givenAttributeReadOnly
used forgetLock()
.
-
withValidator
- Parameters:
newValidator
- the newValidator
.- Returns:
- a new instance of
PropertyMetadata
with the givenValidator
used forgetValidator()
.
-
withExpression
- Parameters:
newExpression
- the newexpression
.- Returns:
- a new instance of
PropertyMetadata
with the givenSupplier
used forgetExpression()
.
-
getLock
-
of
static <V> PropertyMetadata<V> of(AttributeReadOnly lock, Validator<? super V> validator, Supplier<? extends V> expression, Type valueType, Map<String, Object> map) - Type Parameters:
V
- type of theproperty value
.- Parameters:
lock
- thelock
(owning bean).validator
- thevalidator
.expression
- theexpression
.valueType
- thevalue type
.map
- themetadata
Map
.- Returns:
- the new
PropertyMetadata
.
-
of
- Type Parameters:
V
- type of theproperty value
.- Parameters:
lock
- thelock
(owning bean).- Returns:
- the new
PropertyMetadata
.
-
of
- Type Parameters:
V
- type of theproperty value
.- Parameters:
lock
- thelock
(owning bean).validator
- thevalidator
.- Returns:
- the new
PropertyMetadata
.
-
of
static <V> PropertyMetadata<V> of(AttributeReadOnly lock, Validator<? super V> validator, Supplier<? extends V> expression) - Type Parameters:
V
- type of theproperty value
.- Parameters:
lock
- thelock
(owning bean).validator
- thevalidator
.expression
- theexpression
.- Returns:
- the new
PropertyMetadata
.
-
of
static <V> PropertyMetadata<V> of(AttributeReadOnly lock, Validator<? super V> validator, Supplier<? extends V> expression, Type valueType) - Type Parameters:
V
- type of theproperty value
.- Parameters:
lock
- thelock
(owning bean).validator
- thevalidator
.expression
- theexpression
.valueType
- thevalue type
.- Returns:
- the new
PropertyMetadata
.
-
ofExpression
- Type Parameters:
V
- type of theproperty value
.- Parameters:
lock
- thelock
(owning bean).validator
- thevalidator
.expression
- theexpression
.- Returns:
- the new
PropertyMetadata
.
-