T
- The type of entityV
- The type of propertypublic abstract class AbstractPropertyMetaData<T,V> extends Object implements PropertyMetaData<T,V>
PropertyMetaData
interface.Modifier and Type | Field and Description |
---|---|
protected Constraint<? super V> |
constraint
Constraint to be used for property value validation.
|
protected Converter<V> |
converter
Converter to be used for property value conversion into and from string.
|
protected V |
defaultValue
Property default value.
|
protected String |
name
Property name.
|
Modifier | Constructor and Description |
---|---|
protected |
AbstractPropertyMetaData(String name,
Converter<V> converter,
Constraint<? super V> constraint,
V defaultValue)
Constructs a new
AbstractPropertyMetaData with the specified
name, converter, constraint and default value. |
Modifier and Type | Method and Description |
---|---|
V |
cast(Object value)
Casts the specified value to this property type.
|
boolean |
equals(Object obj)
Determines if this property metadata equals to the specified one.
|
Constraint<? super V> |
getConstraint()
Returns constraint to be used for property value validation.
|
Converter<V> |
getConverter()
Returns converter to be used for property value conversion into and from
string.
|
V |
getDefaultValue()
Returns default value of this property.
|
String |
getName()
Returns name of this property.
|
Class<V> |
getType()
Returns type of this property.
|
V |
getValue(T entity)
Returns value of this property for the specified entity.
|
int |
hashCode()
Returns a hash code value for this property metadata.
|
boolean |
isReadable()
Determines if this property is readable.
|
boolean |
isRequired()
Determines if this property requires value.
|
boolean |
isWriteable()
Determines if this property is writeable.
|
void |
setValue(T entity,
Object value)
Assigns value of this property for the specified entity.
|
String |
toString()
Returns string representing this property metadata.
|
protected final String name
protected final Converter<V> converter
protected final Constraint<? super V> constraint
protected final V defaultValue
protected AbstractPropertyMetaData(String name, Converter<V> converter, Constraint<? super V> constraint, V defaultValue)
AbstractPropertyMetaData
with the specified
name, converter, constraint and default value.name
- Property name.converter
- Converter to be used for property value conversion
into and from string.constraint
- Constraint to be used for property value validation.defaultValue
- Property default value.IllegalArgumentException
- if the specified name or converter is
null
or name is empty.public final String getName()
getName
in interface ElementMetaData<T,V>
public final V getDefaultValue()
getDefaultValue
in interface ElementMetaData<T,V>
public final Converter<V> getConverter()
getConverter
in interface PropertyMetaData<T,V>
public final Constraint<? super V> getConstraint()
null
.getConstraint
in interface MetaData<V>
public boolean isRequired()
isRequired
in interface PropertyMetaData<T,V>
true
if this property requires value;
false
otherwise.public boolean isReadable()
This method always returns true
and should be overriden
in subclasses.
isReadable
in interface PropertyMetaData<T,V>
true
.public boolean isWriteable()
This method always returns true
and should be overriden
in subclasses.
isWriteable
in interface PropertyMetaData<T,V>
true
.public V cast(Object value)
cast
in interface MetaData<V>
value
- Value to be cast.ClassCastException
- if the specified value is not assignable to
this property type.public V getValue(T entity)
This method always throws UnsupportedOperationException
and should be overriden in subclasses.
getValue
in interface PropertyMetaData<T,V>
entity
- Entity whose property value should be returned.UnsupportedOperationException
- always.public void setValue(T entity, Object value)
This method always throws UnsupportedOperationException
and should be overriden in subclasses.
setValue
in interface PropertyMetaData<T,V>
entity
- Entity whose property value should be assigned.value
- New property value.UnsupportedOperationException
- always.public int hashCode()
public boolean equals(Object obj)
Copyright © 2011–2020 FoxLabs. All rights reserved.