Class Junction.All<T extends Comparable<T>>

java.lang.Object
com.github.tommyettinger.ds.Junction.All<T>
Type Parameters:
T - the Comparable type shared by all Terms in this Junction
All Implemented Interfaces:
Term<T>, Comparable<Term<T>>
Enclosing class:
Junction<T extends Comparable<T>>

public static class Junction.All<T extends Comparable<T>> extends Object implements Term<T>
Takes one or more Terms and matches if all of those Terms match.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    final ObjectList<Term<T>>
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    All()
     
    All(Term<T> left, Term<T> right)
     
    All(Collection<Term<T>> coll)
     
    All(T... items)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    If this Term has sub-Terms, which this calls children, calling appendChildren will take all children one level descendant from this and place them into appending, in undefined order.
    Attempts to convert this Term and its children (recursively) to a single possible format for potentially many different internal representations.
    int
     
    final boolean
    Used primarily to check for equality between Terms, not to act like Term.match(Collection).
    int
     
    boolean
    match(Collection<? extends T> coll)
    A predicate that checks if the given Collection of T satisfies this Term.
    Gets a plain-English name, typically all lower-case and one word, that describes what operation this Term performs.
    static <T extends Comparable<T>>
    Junction.All<T>
    of(Term<T>... terms)
     
    Modifies the given Collection of T by removing any items that match this Term.
    char
    Gets a single char constant that represents this Term and determines its comparison order in the event of a tie.
    Slightly different from the normal toString() behavior, this may incorporate Term.name() but doesn't need to, and if it contains multiple parts, they should be separated by Term.symbol().
    If this term has a T value (not inside another wrapping Term), this returns that value.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

  • Constructor Details

  • Method Details

    • match

      public boolean match(Collection<? extends T> coll)
      Description copied from interface: Term
      A predicate that checks if the given Collection of T satisfies this Term. Returns true if this Term matches the given Collection, or false otherwise.
      Specified by:
      match in interface Term<T extends Comparable<T>>
      Parameters:
      coll - a Collection of T that will not be modified
      Returns:
      true if coll matches, or false otherwise
    • remove

      public Collection<T> remove(Collection<T> coll)
      Description copied from interface: Term
      Modifies the given Collection of T by removing any items that match this Term. You can use Junction.negate() on an outer Junction to flip this to perform the converse operation to removing, filtering.
      Specified by:
      remove in interface Term<T extends Comparable<T>>
      Parameters:
      coll - a Collection of T that may be modified
      Returns:
      usually coll, after modifications
    • appendChildren

      public void appendChildren(Collection<Term<T>> appending)
      Description copied from interface: Term
      If this Term has sub-Terms, which this calls children, calling appendChildren will take all children one level descendant from this and place them into appending, in undefined order. Typically, after appendChildren() has been called at least once and doesn't need to append more, calling code will sort appending.
      Specified by:
      appendChildren in interface Term<T extends Comparable<T>>
      Parameters:
      appending - will be modified by appending child Terms
    • value

      public T value()
      Description copied from interface: Term
      If this term has a T value (not inside another wrapping Term), this returns that value. Otherwise, this returns null.
      Specified by:
      value in interface Term<T extends Comparable<T>>
      Returns:
      a T value not inside another wrapping Term, or null if this Term doesn't have a T value.
    • canonicalize

      public Term<T> canonicalize()
      Description copied from interface: Term
      Attempts to convert this Term and its children (recursively) to a single possible format for potentially many different internal representations. This mostly means things like Not(Not(Leaf("something"))) can be simplified to Leaf("something"), and chains of Any of Any of Any of... can be simplified to one Any with more items. The last case also works for All, but not One.
      Specified by:
      canonicalize in interface Term<T extends Comparable<T>>
      Returns:
      a unified formatting of the data this held, modifying this Term in place.
    • symbol

      public char symbol()
      Description copied from interface: Term
      Gets a single char constant that represents this Term and determines its comparison order in the event of a tie. Every Term class should return a different char from this method.
      Specified by:
      symbol in interface Term<T extends Comparable<T>>
      Returns:
      a char that represents this Term and is used to break ties in sorting.
    • name

      public String name()
      Description copied from interface: Term
      Gets a plain-English name, typically all lower-case and one word, that describes what operation this Term performs.
      Specified by:
      name in interface Term<T extends Comparable<T>>
      Returns:
      a typically lower-case single-word name describing what this Term does
    • toString

      public String toString()
      Description copied from interface: Term
      Slightly different from the normal toString() behavior, this may incorporate Term.name() but doesn't need to, and if it contains multiple parts, they should be separated by Term.symbol().
      Specified by:
      toString in interface Term<T extends Comparable<T>>
      Overrides:
      toString in class Object
      Returns:
      a String representation of this Term, or sometimes only its contents
    • equals

      public final boolean equals(Object o)
      Description copied from interface: Term
      Used primarily to check for equality between Terms, not to act like Term.match(Collection).
      Specified by:
      equals in interface Term<T extends Comparable<T>>
      Overrides:
      equals in class Object
      Parameters:
      o - another Object that must be a Term of the same class for this to be able to return true
      Returns:
      true if and only if o is a Term of the same class, and this Term is equivalent to o
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • compareTo

      public int compareTo(Term<T> o)
      Specified by:
      compareTo in interface Comparable<T extends Comparable<T>>
    • of

      @SafeVarargs public static <T extends Comparable<T>> Junction.All<T> of(Term<T>... terms)