Interface Attributes
-
- All Known Subinterfaces:
PortfolioItemInfo
- All Known Implementing Classes:
EtdContractSpec
,PositionInfo
,SecurityInfo
,SimpleAttributes
,TradeInfo
public interface Attributes
Additional attributes that can be associated with a model object.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method 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 isequal
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.
-
-
-
Method Detail
-
empty
static Attributes empty()
Obtains an empty instance.The
withAttribute(AttributeType, Object)
method can be used on the instance to add attributes.- Returns:
- the empty instance
-
of
static <T> Attributes of(AttributeType<T> type, T value)
Obtains an instance with a single attribute.The
withAttribute(AttributeType, Object)
method can be used on the instance to add more attributes.- Type Parameters:
T
- the type of the attribute value- Parameters:
type
- the type providing meaning to the valuevalue
- the value- Returns:
- the instance
-
getAttributeTypes
default ImmutableSet<AttributeType<?>> getAttributeTypes()
Gets the attribute types that are available.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).
- Returns:
- the attribute types
-
getAttribute
default <T> T getAttribute(AttributeType<T> type)
Gets the attribute associated with the specified 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.
- Type Parameters:
T
- the type of the attribute value- Parameters:
type
- the type to find- Returns:
- the attribute value
- Throws:
IllegalArgumentException
- if the attribute is not found
-
containsAttribute
default <T> boolean containsAttribute(AttributeType<T> type)
Determines if an attribute associated with the specified type is present.- Type Parameters:
T
- the type of the attribute value- Parameters:
type
- the type to find- Returns:
- true if a matching attribute is present
-
containsAttribute
default <T> boolean containsAttribute(AttributeType<T> type, T attributeValue)
Determines if an attribute associated with the specified type is present and its value isequal
to the supplied value.- Type Parameters:
T
- the type of the attribute value- Parameters:
type
- the type to findattributeValue
- the value to match against- Returns:
- true if a matching attribute is present
-
findAttribute
<T> Optional<T> findAttribute(AttributeType<T> type)
Finds the attribute associated with the specified 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.
- Type Parameters:
T
- the type of the result- Parameters:
type
- the type to find- Returns:
- the attribute value
-
withAttribute
<T> Attributes withAttribute(AttributeType<T> type, T value)
Returns a copy of this instance with the attribute added.This returns a new instance with the specified attribute added. The attribute is added using
Map.put(type, value)
semantics.- Type Parameters:
T
- the type of the attribute value- Parameters:
type
- the type providing meaning to the valuevalue
- the value- Returns:
- a new instance based on this one with the attribute added
-
withAttributes
default Attributes withAttributes(Attributes other)
Returns a copy of this instance with the attributes added.This returns a new instance with the specified attributes added. The attributes are added using
Map.putAll(type, value)
semantics.- Parameters:
other
- the other instance to copy from- Returns:
- an instance based on this one with the attributes from the other instance
-
-