Package org.pepsoft.util
Class AttributeKey<T>
java.lang.Object
org.pepsoft.util.AttributeKey<T>
- Type Parameters:
T- The value type of the attribute.
- Direct Known Subclasses:
IntegerAttributeKey,LongAttributeKey,StringAttributeKey
A utility class for getting a typed attribute value with a default
conveniently. This class is
Serializable, but only if the concrete
type of all the values is serializable!-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanGet a value for this attribute from a map of string to native value types.getFromString(Map<String, String> values) Get a value for this attribute from a map of string to strings.final inthashCode()Convert an instance ofAttributeKeyto a string.Convert a string representation ofAttributeKeyto its native type.
-
Field Details
-
key
-
defaultValue
-
-
Constructor Details
-
AttributeKey
-
AttributeKey
-
-
Method Details
-
getFromString
Get a value for this attribute from a map of string to strings.- Parameters:
values- The map from which to get the value.- Returns:
- The value of this attribute in the specified map, or the default value if the map does not contain the attribute.
-
get
Get a value for this attribute from a map of string to native value types.- Parameters:
values- The map from which to get the value.- Returns:
- The value of this attribute in the specified map, or the default value if the map does not contain the attribute.
-
toString
Convert an instance ofAttributeKeyto a string.- Parameters:
value- The value to convert. Will never benull.- Returns:
- A string representation of the value.
-
toValue
Convert a string representation ofAttributeKeyto its native type.This implementation always throws an
UnsupportedOperationException. Subclasses should override this method to implement it.- Parameters:
str- The string representation to convert. Will never benull.- Returns:
- A corresponding instance of
AttributeKey.
-
equals
-
hashCode
public final int hashCode()
-