Package com.github.tommyettinger.ds
Class Junction.Any<T extends Comparable<T>>
java.lang.Object
com.github.tommyettinger.ds.Junction.Any<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>>
Takes one or more Terms and matches if any of those Terms match.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidappendChildren(Collection<Term<T>> appending) If this Term has sub-Terms, which this calls children, calling appendChildren will take all children one level descendant from this and place them intoappending, in undefined order.Attempts to convert this Term and its children (recursively) to a single possible format for potentially many different internal representations.intfinal booleanUsed primarily to check for equality between Terms, not to act likeTerm.match(Collection).inthashCode()booleanmatch(Collection<? extends T> coll) A predicate that checks if the given Collection of T satisfies this Term.name()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.Any<T>remove(Collection<T> coll) Modifies the given Collection of T by removing any items that match this Term.charsymbol()Gets a single char constant that represents this Term and determines its comparison order in the event of a tie.toString()Slightly different from the normal toString() behavior, this may incorporateTerm.name()but doesn't need to, and if it contains multiple parts, they should be separated byTerm.symbol().value()If this term has a T value (not inside another wrapping Term), this returns that value.
-
Field Details
-
contents
-
-
Constructor Details
-
Any
public Any() -
Any
-
Any
-
Any
-
-
Method Details
-
match
Description copied from interface:TermA 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:
matchin interfaceTerm<T extends Comparable<T>>- Parameters:
coll- a Collection of T that will not be modified- Returns:
- true if coll matches, or false otherwise
-
remove
Description copied from interface:TermModifies the given Collection of T by removing any items that match this Term. You can useJunction.negate()on an outer Junction to flip this to perform the converse operation to removing, filtering.- Specified by:
removein interfaceTerm<T extends Comparable<T>>- Parameters:
coll- a Collection of T that may be modified- Returns:
- usually coll, after modifications
-
appendChildren
Description copied from interface:TermIf this Term has sub-Terms, which this calls children, calling appendChildren will take all children one level descendant from this and place them intoappending, in undefined order. Typically, after appendChildren() has been called at least once and doesn't need to append more, calling code will sortappending.- Specified by:
appendChildrenin interfaceTerm<T extends Comparable<T>>- Parameters:
appending- will be modified by appending child Terms
-
value
Description copied from interface:TermIf this term has a T value (not inside another wrapping Term), this returns that value. Otherwise, this returns null.- Specified by:
valuein interfaceTerm<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
Description copied from interface:TermAttempts to convert this Term and its children (recursively) to a single possible format for potentially many different internal representations. This mostly means things likeNot(Not(Leaf("something")))can be simplified toLeaf("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:
canonicalizein interfaceTerm<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:TermGets 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:
symbolin interfaceTerm<T extends Comparable<T>>- Returns:
- a char that represents this Term and is used to break ties in sorting.
-
name
Description copied from interface:TermGets a plain-English name, typically all lower-case and one word, that describes what operation this Term performs.- Specified by:
namein interfaceTerm<T extends Comparable<T>>- Returns:
- a typically lower-case single-word name describing what this Term does
-
toString
Description copied from interface:TermSlightly different from the normal toString() behavior, this may incorporateTerm.name()but doesn't need to, and if it contains multiple parts, they should be separated byTerm.symbol(). -
equals
Description copied from interface:TermUsed primarily to check for equality between Terms, not to act likeTerm.match(Collection). -
hashCode
public int hashCode() -
compareTo
- Specified by:
compareToin interfaceComparable<T extends Comparable<T>>
-
of
-