public interface Attributes
| Modifier and Type | Method and Description |
|---|---|
default <T> boolean |
containsAttribute(AttributeType<T> type)
Determines if an attribute associated with the specified type is present.
|
default <T> boolean |
containsAttribute(AttributeType<T> type,
T attributeValue)
Determines if an attribute associated with the specified type is present and its value is
equal
to the supplied value. |
static Attributes |
empty()
Obtains an empty instance.
|
<T> Optional<T> |
findAttribute(AttributeType<T> type)
Finds the attribute associated with the specified type.
|
default <T> T |
getAttribute(AttributeType<T> type)
Gets the attribute associated with the specified type.
|
default ImmutableSet<AttributeType<?>> |
getAttributeTypes()
Gets the attribute types that are available.
|
static <T> Attributes |
of(AttributeType<T> type,
T value)
Obtains an instance with a single attribute.
|
<T> Attributes |
withAttribute(AttributeType<T> type,
T value)
Returns a copy of this instance with the attribute added.
|
default Attributes |
withAttributes(Attributes other)
Returns a copy of this instance with the attributes added.
|
static Attributes empty()
The withAttribute(AttributeType, Object) method can be used on
the instance to add attributes.
static <T> Attributes of(AttributeType<T> type, T value)
The withAttribute(AttributeType, Object) method can be used on
the instance to add more attributes.
T - the type of the attribute valuetype - the type providing meaning to the valuevalue - the valuedefault ImmutableSet<AttributeType<?>> getAttributeTypes()
See AttributeType.captureWildcard() for a way to capture the wildcard type.
The default implementation returns an empty set (backwards compatibility prevents an abstract method for now).
default <T> T getAttribute(AttributeType<T> type)
This method obtains the specified attribute. This allows an attribute to be obtained if available.
If the attribute is not found, an exception is thrown.
T - the type of the attribute valuetype - the type to findIllegalArgumentException - if the attribute is not founddefault <T> boolean containsAttribute(AttributeType<T> type)
T - the type of the attribute valuetype - the type to finddefault <T> boolean containsAttribute(AttributeType<T> type, T attributeValue)
equal
to the supplied value.T - the type of the attribute valuetype - the type to findattributeValue - the value to match against<T> Optional<T> findAttribute(AttributeType<T> type)
This method obtains the specified attribute. This allows an attribute to be obtained if available.
If the attribute is not found, optional empty is returned.
T - the type of the resulttype - the type to find<T> Attributes withAttribute(AttributeType<T> type, T value)
This returns a new instance with the specified attribute added.
The attribute is added using Map.put(type, value) semantics.
T - the type of the attribute valuetype - the type providing meaning to the valuevalue - the valuedefault Attributes withAttributes(Attributes other)
This returns a new instance with the specified attributes added.
The attributes are added using Map.putAll(type, value) semantics.
other - the other instance to copy fromCopyright 2009-Present by OpenGamma Inc. and individual contributors
Apache v2 licensed
Additional documentation can be found at strata.opengamma.io.