Class QueryCollectionPathExpression

  • All Implemented Interfaces:
    HasFromList, Queryable, QueryPathExpression, QueryPathExpressionWithSelect, QuerySelectable

    public class QueryCollectionPathExpression
    extends java.lang.Object
    implements QueryPathExpressionWithSelect, Queryable, HasFromList
    An element that can appear in the SELECT clause of a query, representing extra data to be collected for the Results - namely a collection or reference referenced in an object in the results. The column in the Results associated with this object will be of type Collection. In order to reference further into this field, this class contains many of the features of Query. That is, you can add QueryFields and QueryPathExpressions to the SELECT list. You can also add QueryClasses to the FROM list and constraints to the WHERE clause. A default QueryClass corresponding to the field is available from the getDefaultClass() method.
    Author:
    Matthew Wakeling
    • Constructor Summary

      Constructors 
      Constructor Description
      QueryCollectionPathExpression​(QueryClass qc, java.lang.String fieldName)
      Constructs a QueryCollectionPathExpression representing a reference from the given QueryClass to the given field name.
      QueryCollectionPathExpression​(QueryClass qc, java.lang.String fieldName, java.lang.Class<?>... subclasses)
      Constructs a QueryCollectionPathExpression representing a reference from the given QueryClass to the given field name, constrained to be a particular subclass.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addFrom​(FromElement node)
      Adds an element to the FROM list.
      void addFrom​(FromElement node, java.lang.String alias)
      Adds an element to the FROM list, including an alias.
      void addToSelect​(QuerySelectable selectable)
      Adds an element to the SELECT list.
      Constraint getConstraint()
      Returns the additional constraint.
      QueryClass getDefaultClass()
      Returns the QueryClass that represents the collection in this object.
      java.lang.String getFieldName()
      Returns the name of the field.
      java.util.List<FromElement> getFrom()
      Returns the additional FROM list.
      Query getQuery​(java.util.Collection<? extends InterMineObject> bag)
      Returns the Query that will fetch the data represented by this object, given a Collection of objects to fetch it for.
      QueryClass getQueryClass()
      Returns the QueryClass of which the field is a member.
      java.util.List<QuerySelectable> getSelect()
      Returns the SELECT list.
      java.lang.Class<? extends FastPathObject> getSubclass()
      Returns the subclass if it exists.
      java.lang.Class<?> getType()
      Get Java type represented by this item.
      boolean isCollection()
      Returns true if the reference is a collection.
      boolean isSingleton()
      Returns true if the SELECT list is empty or if singleton results are requested.
      void setConstraint​(Constraint c)
      Sets the additional constraint.
      void setSingleton​(boolean singleton)
      Sets whether the collection should be a singleton collection, or whether it should be a collection of ResultRows.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • QueryCollectionPathExpression

        public QueryCollectionPathExpression​(QueryClass qc,
                                             java.lang.String fieldName)
        Constructs a QueryCollectionPathExpression representing a reference from the given QueryClass to the given field name.
        Parameters:
        qc - the QueryClass
        fieldName - the name of the relevant collection or reference
        Throws:
        java.lang.IllegalArgumentException - if the field is not a collection or reference
      • QueryCollectionPathExpression

        public QueryCollectionPathExpression​(QueryClass qc,
                                             java.lang.String fieldName,
                                             java.lang.Class<?>... subclasses)
        Constructs a QueryCollectionPathExpression representing a reference from the given QueryClass to the given field name, constrained to be a particular subclass.
        Parameters:
        qc - the QueryClass
        fieldName - the name of the relevant collection or reference
        subclasses - a Class that is a subclass of the field class
        Throws:
        java.lang.IllegalArgumentException - if the field is not a collection or reference
    • Method Detail

      • getFieldName

        public java.lang.String getFieldName()
        Returns the name of the field.
        Returns:
        field name
      • getSubclass

        public java.lang.Class<? extends FastPathObject> getSubclass()
        Returns the subclass if it exists.
        Returns:
        the subclass
      • getType

        public java.lang.Class<?> getType()
        Get Java type represented by this item.
        Specified by:
        getType in interface QuerySelectable
        Returns:
        class describing the type
      • getDefaultClass

        public QueryClass getDefaultClass()
        Returns the QueryClass that represents the collection in this object.
        Returns:
        a QueryClass
      • addFrom

        public void addFrom​(FromElement node)
        Adds an element to the FROM list.
        Specified by:
        addFrom in interface HasFromList
        Parameters:
        node - a QueryNode
      • addFrom

        public void addFrom​(FromElement node,
                            java.lang.String alias)
        Adds an element to the FROM list, including an alias.
        Parameters:
        node - a FromElement
        alias - the alias
      • getFrom

        public java.util.List<FromElement> getFrom()
        Returns the additional FROM list.
        Returns:
        a List
      • setConstraint

        public void setConstraint​(Constraint c)
        Sets the additional constraint.
        Specified by:
        setConstraint in interface Queryable
        Parameters:
        c - a Constraint
      • getConstraint

        public Constraint getConstraint()
        Returns the additional constraint.
        Specified by:
        getConstraint in interface Queryable
        Returns:
        a Constraint
      • getQuery

        public Query getQuery​(java.util.Collection<? extends InterMineObject> bag)
        Returns the Query that will fetch the data represented by this object, given a Collection of objects to fetch it for.
        Parameters:
        bag - a Collection of objects to fetch data for, or null to not constrain. If the reference is a collection, then this bag should contain the objects that have the collection. If the reference is to an object, then this bag should contain the objects pointed to by the reference
        Returns:
        a Query
      • isSingleton

        public boolean isSingleton()
        Returns true if the SELECT list is empty or if singleton results are requested.
        Returns:
        a boolean
      • setSingleton

        public void setSingleton​(boolean singleton)
        Sets whether the collection should be a singleton collection, or whether it should be a collection of ResultRows.
        Parameters:
        singleton - true if the collection should be singletons
      • isCollection

        public boolean isCollection()
        Returns true if the reference is a collection. This class can be used for non-collection references, as it adds the feature of having a FROM list (and with that, allowing a variable number of rows).
        Returns:
        a boolean