Class MultiValueAttribute<O,A>
- java.lang.Object
-
- com.googlecode.cqengine.attribute.support.AbstractAttribute<O,A>
-
- com.googlecode.cqengine.attribute.MultiValueAttribute<O,A>
-
- All Implemented Interfaces:
Attribute<O,A>
- Direct Known Subclasses:
FunctionalMultiValueAttribute
,StandingQueryAttribute
public abstract class MultiValueAttribute<O,A> extends AbstractAttribute<O,A>
Represents an attribute in an object which has multiple values (such as a field which is itself a collection), where all of the values are known to be non-null. Provides a method to read the values from the field given such an object. This type of attribute skips null checks on values at runtime, thereby allowing maximum performance. If this type of attribute encounters a null, it is likely that aNullPointerException
will be thrown. Therefore when it is not possible to know in advance if values might be null, it is recommended to useMultiValueNullableAttribute
instead.- Author:
- Niall Gallagher
-
-
Constructor Summary
Constructors Constructor Description MultiValueAttribute()
Creates an attribute with no name.MultiValueAttribute(Class<O> objectType, Class<A> attributeType)
Creates an attribute with no name, and manually specifies the type of the attribute and its enclosing object.MultiValueAttribute(Class<O> objectType, Class<A> attributeType, String attributeName)
Creates an attribute with the given name, and manually specifies the type of the attribute and its enclosing object.MultiValueAttribute(String attributeName)
Creates an attribute with the given name.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description abstract Iterable<A>
getValues(O object, QueryOptions queryOptions)
Returns the non-null values of the attribute from the object.-
Methods inherited from class com.googlecode.cqengine.attribute.support.AbstractAttribute
calcHashCode, canEqual, equals, getAttributeName, getAttributeType, getObjectType, hashCode, toString
-
-
-
-
Constructor Detail
-
MultiValueAttribute
public MultiValueAttribute(String attributeName)
Creates an attribute with the given name. This name is not actually used by the query engine except in providing informative exception and debug messages. As such it is recommended, but not required, that a name be provided. A suitable name might be the name of the field to which an attribute refers.- Parameters:
attributeName
- The name for this attribute- See Also:
MultiValueAttribute()
-
MultiValueAttribute
public MultiValueAttribute()
Creates an attribute with no name. A name for the attribute will be generated automatically from the name of the subclass (or anonymous class) which implements the attribute.- See Also:
MultiValueAttribute(String)
-
MultiValueAttribute
public MultiValueAttribute(Class<O> objectType, Class<A> attributeType)
Creates an attribute with no name, and manually specifies the type of the attribute and its enclosing object.- Parameters:
objectType
- The type of the object containing this attributeattributeType
- The type of this attribute
-
MultiValueAttribute
public MultiValueAttribute(Class<O> objectType, Class<A> attributeType, String attributeName)
Creates an attribute with the given name, and manually specifies the type of the attribute and its enclosing object.- Parameters:
objectType
- The type of the object containing this attributeattributeType
- The type of this attributeattributeName
- The name for this attribute
-
-
Method Detail
-
getValues
public abstract Iterable<A> getValues(O object, QueryOptions queryOptions)
Returns the non-null values of the attribute from the object.- Parameters:
object
- The object from which the values of the attribute are requiredqueryOptions
- Optional parameters supplied by the application along with the operation which is causing this attribute to be invoked (either a query, or an update to the collection)- Returns:
- The values for the attribute, which should never be null
-
-