public final class SimpleAttributes extends Object implements Attributes, org.joda.beans.ImmutableBean, Serializable
Additional attributes can be associated with a model object. This is the simplest possible implementation.
| Modifier and Type | Method and Description |
|---|---|
static SimpleAttributes |
empty()
Obtains an empty instance.
|
boolean |
equals(Object obj) |
<T> Optional<T> |
findAttribute(AttributeType<T> type)
Finds the attribute associated with the specified type.
|
static SimpleAttributes |
from(Attributes other)
Obtains an instance from another instance, copying the attributes.
|
ImmutableMap<AttributeType<?>,Object> |
getAttributes()
Gets the attributes.
|
ImmutableSet<AttributeType<?>> |
getAttributeTypes()
Gets the attribute types that are available.
|
int |
hashCode() |
static org.joda.beans.TypedMetaBean<SimpleAttributes> |
meta()
The meta-bean for
SimpleAttributes. |
org.joda.beans.TypedMetaBean<SimpleAttributes> |
metaBean() |
static <T> SimpleAttributes |
of(AttributeType<T> type,
T value)
Obtains an instance with a single attribute.
|
String |
toString() |
<T> SimpleAttributes |
withAttribute(AttributeType<T> type,
T value)
Returns a copy of this instance with the attribute added.
|
SimpleAttributes |
withAttributes(Attributes other)
Returns a copy of this instance with the attributes added.
|
clone, finalize, getClass, notify, notifyAll, wait, wait, waitcontainsAttribute, containsAttribute, getAttributepublic static SimpleAttributes empty()
The withAttribute(AttributeType, Object) method can be used on
the instance to add attributes.
empty in interface Attributespublic static <T> SimpleAttributes of(AttributeType<T> type, T value)
The withAttribute(AttributeType, Object) method can be used on
the instance to add more attributes.
of in interface AttributesT - the type of the attribute valuetype - the type providing meaning to the valuevalue - the valuepublic static SimpleAttributes from(Attributes other)
This can be used to ensure that an instance of Attributes contains
no state apart from attributes.
other - the attributes to copy frompublic ImmutableSet<AttributeType<?>> getAttributeTypes()
Attributes
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).
getAttributeTypes in interface Attributespublic <T> Optional<T> findAttribute(AttributeType<T> type)
AttributesThis method obtains the specified attribute. This allows an attribute to be obtained if available.
If the attribute is not found, optional empty is returned.
findAttribute in interface AttributesT - the type of the resulttype - the type to findpublic <T> SimpleAttributes withAttribute(AttributeType<T> type, T value)
Attributes
This returns a new instance with the specified attribute added.
The attribute is added using Map.put(type, value) semantics.
withAttribute in interface AttributesT - the type of the attribute valuetype - the type providing meaning to the valuevalue - the valuepublic SimpleAttributes withAttributes(Attributes other)
Attributes
This returns a new instance with the specified attributes added.
The attributes are added using Map.putAll(type, value) semantics.
withAttributes in interface Attributesother - the other instance to copy frompublic static org.joda.beans.TypedMetaBean<SimpleAttributes> meta()
SimpleAttributes.public org.joda.beans.TypedMetaBean<SimpleAttributes> metaBean()
metaBean in interface org.joda.beans.Beanpublic ImmutableMap<AttributeType<?>,Object> getAttributes()
Attributes provide the ability to associate arbitrary information in a key-value map.
Copyright 2009-Present by OpenGamma Inc. and individual contributors
Apache v2 licensed
Additional documentation can be found at strata.opengamma.io.