public class Property extends Object implements NamedValueWithSource, Identifiable
Represents a single property. A property consists of a name, a String value, and a source.
| Constructor and Description |
|---|
Property(PropertyName<V> name,
V value)
Creates a new property with a mandatory name and optional value.
|
Property(String name,
String value)
Creates a new property with a mandatory name and optional value.
|
Property(String name,
String value,
String source)
Creates a new property with a mandatory name, optional value, and source.
|
Property(String id,
String name,
String value,
String source)
Creates a new property with a mandatory id, name, optional value, and source.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object o) |
String |
getId()
Returns the id of the property.
|
String |
getName()
Returns the name of the property.
|
String |
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.
|
int |
hashCode() |
String |
toString() |
Property |
withId(String id)
Returns a new property with the given id and the current name, value, and source.
|
Property |
withSource(String source)
Returns a new property with the given source and the current id, name, and value.
|
public Property(PropertyName<V> name, V value)
Creates a new property with a mandatory name and optional value.
name - the name of the propertyvalue - the value of the propertypublic Property(String name, String value)
Creates a new property with a mandatory name and optional value.
name - the name of the propertyvalue - the value of the propertypublic Property(String name, String value, String source)
Creates a new property with a mandatory name, optional value, and source.
name - the name of the propertyvalue - the value of the propertysource - the source of the propertypublic String getId()
Returns the id of the property.
getId in interface Identifiablepublic String getName()
Returns the name of the property.
getName in interface NamedValuepublic String getValue()
Returns the value of the property.
getValue in interface NamedValuepublic <T> T getValue(Class<T> expectedType)
Convenience method for returning the value of the property cast to the expected type. If the property value is not of the expected type and not null, an IllegalArgumentException is thrown.
getValue in interface NamedValueT - 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)
Convenience method for returning the value of the property cast to the expected type. If the property value is not of the expected type and not null, an IllegalArgumentException is thrown.
getValue in interface NamedValueS - the type of the valueexpectedType - the expected type of the property valueIllegalArgumentException - thrown if the cast is not possiblepublic String getSource()
Returns the source of the property.
getSource in interface NamedValueWithSourcepublic Property withId(String id)
Returns a new property with the given id and the current name, value, and source.
id - the new id of the propertypublic Property withSource(String source)
Returns a new property with the given source and the current id, name, and value.
source - the new source of the propertyCopyright © 2010 - 2019 edorasware ag. All Rights Reserved.