Class AnyToAnyRestriction

java.lang.Object
net.sf.basedb.core.query.AnyToAnyRestriction
All Implemented Interfaces:
QueryElement, Restriction

public class AnyToAnyRestriction extends Object implements Restriction
Expression that can be used to filter on the existence or non-existence of a named any-to-any link.
Since:
3.6
Author:
nicklas
  • Field Details

    • alias

      private final String alias
    • linkName

      private final String linkName
    • linkedTo

      private final Item linkedTo
    • linkedQuery

      private final EntityQuery linkedQuery
    • linkedRestriction

      private final Restriction linkedRestriction
    • parameterName

      private String parameterName
  • Constructor Details

    • AnyToAnyRestriction

      private AnyToAnyRestriction(String alias, String linkName, Item linkedTo, boolean hasLink, EntityQuery linkedQuery)
  • Method Details

    • exists

      public static AnyToAnyRestriction exists(String alias, String linkName, Item linkedTo, EntityQuery linkedQuery)
      Create a restriction that restrict a query to return items that has a linked item with the given link name.
      Parameters:
      alias - Alias to resolve the link against, use null to resolve the link agains the root entity
      linkName - The name of the link (required)
      linkedTo - The type of the linked item (optional)
      linkedQuery - An optional query that the linked items must match
    • missing

      public static AnyToAnyRestriction missing(String alias, String linkName, Item linkedTo, EntityQuery linkedQuery)
      Create a restriction that restrict a query to return items that is missing a linked item with the given link name.
      Parameters:
      alias - Alias to resolve the link against, use null to resolve the link agains the root entity
      linkName - The name of the link (required)
      linkedTo - The type of the linked item (optional)
      linkedQuery - An optional query that the linked items must not match
    • toQl

      public String toQl(Query query, DbControl dc)
      Description copied from interface: QueryElement
      Create a query language string of the query element. Use the Query.getQueryType() method to find out which query language is wanted in case the element requires different syntax for different languages.
      Specified by:
      toQl in interface QueryElement
      Parameters:
      query - The query that is about to be executed
      dc - The DbControl object used to execute the query
    • getChildren

      public Collection<? extends QueryElement> getChildren()
      Description copied from interface: QueryElement
      Get the children of this query element or null if it has no children. For example the AddExpression has two children, the expression beeing added.
      Specified by:
      getChildren in interface QueryElement
      Returns:
      A collection or null
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object other)
      This expression is equal to another AnyToAnyRestriction if their named link, 'hasLink' and subquery restriction are the same.
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object