public final class Property extends Object implements NamedValueWithSource, Identifiable<PropertyId>
Constructor and Description |
---|
Property(PropertyId id,
String name,
String value,
EntityId source)
Creates a new property with a mandatory id, name, optional value, and source.
|
Property(String name,
String value)
Creates a new property with a mandatory name and optional value.
|
Property(String name,
String value,
EntityId source)
Creates a new property with a mandatory name, optional value, and source.
|
Modifier and Type | Method and Description |
---|---|
PropertyId |
getId()
Returns the id of the property.
|
String |
getName()
Returns the name of the property.
|
EntityId |
getSource()
Returns the source of the property.
|
String |
getValue()
Returns the value of the property.
|
<T> T |
getValue(Class<T> expectedType)
Convenience method for returning the value of the property cast to the expected type.
|
<S> S |
getValue(com.google.common.reflect.TypeToken<S> expectedType)
Convenience method for returning the value of the property cast to the expected type.
|
String |
toString() |
Property |
withId(PropertyId id)
Returns a new property with the given id and the current name, value, and source.
|
Property |
withSource(EntityId source)
Returns a new property with the given source and the current id, name, and value.
|
public Property(String name, String value)
name
- the name of the propertyvalue
- the value of the propertypublic Property(String name, String value, EntityId source)
name
- the name of the propertyvalue
- the value of the propertysource
- the source of the propertypublic Property(PropertyId id, String name, String value, EntityId source)
id
- the id of the propertyname
- the name of the propertyvalue
- the value of the propertysource
- the source of the propertypublic PropertyId getId()
getId
in interface Identifiable<PropertyId>
public String getName()
getName
in interface NamedValue
public String getValue()
getValue
in interface NamedValue
public <T> T getValue(Class<T> expectedType)
IllegalArgumentException
is thrown.getValue
in interface NamedValue
T
- the type of the valueexpectedType
- the expected type of the property valueIllegalArgumentException
- thrown if the cast is not possiblepublic <S> S getValue(com.google.common.reflect.TypeToken<S> expectedType)
IllegalArgumentException
is thrown.getValue
in interface NamedValue
S
- the type of the valueexpectedType
- the expected type of the property valueIllegalArgumentException
- thrown if the cast is not possiblepublic EntityId getSource()
getSource
in interface NamedValueWithSource
public Property withId(PropertyId id)
id
- the new id of the propertypublic Property withSource(EntityId source)
source
- the new source of the propertyCopyright © 2010 - 2018 edorasware ag. All Rights Reserved.