Class 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 a NullPointerException will be thrown. Therefore when it is not possible to know in advance if values might be null, it is recommended to use MultiValueNullableAttribute instead.

    Author:
    Niall Gallagher
    • 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 attribute
        attributeType - 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 attribute
        attributeType - The type of this attribute
        attributeName - 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 required
        queryOptions - 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