Class Pattern<A>

java.lang.Object
eu.bandm.tools.ops.Pattern<A>
Direct Known Subclasses:
Pattern.Contravariant, Pattern.Variable

@Deprecated public abstract class Pattern<A> extends Object
Deprecated.
  • Field Details

  • Constructor Details

    • Pattern

      protected Pattern()
      Deprecated.
      Base constructor with no toString representation. Creates an inactive pattern.
  • Method Details

    • match

      public abstract boolean match(A x)
      Deprecated.
      Attempt to match this pattern against a given object. If the class of this pattern imposes a specific order on matches, the first one is chosen. The pattern is activated on success, but deactivated on failure.
    • matchAgain

      public boolean matchAgain()
      Deprecated.
      Attempt to re-match this pattern against a previously matched object. If the class of this pattern imposes a specific order on matches, they are chosen in that order, beginning with the second one. The pattern is activated on success, but deactivated on failure. The behaviour of this method is unspecified if the pattern is currently deactivated.

      Patterns classes that do not overwrite this method guarantee

    • cut

      public void cut(boolean recursively)
      Deprecated.
    • clear

      public void clear(boolean recursively)
      Deprecated.
    • matchOnce

      public boolean matchOnce(A x)
      Deprecated.
    • bindsVariable

      public abstract boolean bindsVariable(Pattern.Variable x)
      Deprecated.
    • disturbsVariable

      public abstract boolean disturbsVariable(Pattern.Variable x)
      Deprecated.
    • savesVariable

      public abstract boolean savesVariable(Pattern.Variable x)
      Deprecated.
    • isDeterministic

      public abstract boolean isDeterministic()
      Deprecated.
    • variable

      public static <A> Pattern.Variable<A> variable()
      Deprecated.
      Creates a new anonymous pattern variable.
    • variable

      public static <A> Pattern.Variable<A> variable(String name)
      Deprecated.
      Creates a new named pattern variable.
    • uniquely

      public final Pattern<A> uniquely()
      Deprecated.
      Returns a pattern that matches if and only if this pattern has a unique match.

      A patterns of this class is deterministic.

    • limit

      public final Pattern<A> limit(int n)
      Deprecated.
    • any

      public static final <A> Pattern.Contravariant<A> any()
      Deprecated.
      Return a pattern that matches anything. A pattern returned by this method is deterministic and binds no variables.
    • none

      public static final <A> Pattern.Contravariant<A> none()
      Deprecated.
      Return a pattern that matches nothing.

      A pattern returned by this method is vacuously deterministic and binds all variables.

    • eq

      public static <A> Pattern.Contravariant<A> eq(A a)
      Deprecated.
      Return a pattern that matches objects equal to a given reference. Equality is determined by Object.equals(java.lang.Object) if an object is given, or by == if null is given instead.

      A pattern returned by this method is deterministic and bings no variables.

      Parameters:
      a - an object to compare with or null.
    • p_null

      public static <A> Pattern.Contravariant<A> p_null()
      Deprecated.
      Return a pattern that matches only the null reference.

      A pattern returned by this method is deterministic and binds no variables.

    • and

      public Pattern.Contravariant<A> and(Pattern<A> p)
      Deprecated.
    • or

      public Pattern.Contravariant<A> or(Pattern<A> p)
      Deprecated.
    • both

      public static final <A> Pattern.Contravariant<A> both(Pattern<? super A> p, Pattern<? super A> q)
      Deprecated.
      Combine two patterns conjunctively.

      A pattern returned by this method is deterministic if and only if both argument patterns are deterministic. A pattern returned by this method is ordered if and only if both argument patterns are ordered. It binds all variables bound by either argument pattern.

      Since the matches of the second argument pattern are repeated for each successful match of the first, it is more efficient to give arguments in decreasing order of matching costs.

      Parameters:
      p - an argument pattern
      q - another argument pattern
      Returns:
      a pattern that has a successful match for each combination of successful matches of the argument patterns. If both argument patterns are ordered, the resulting order is the lexical order of the pairs.
    • either

      public static final <A> Pattern.Contravariant<A> either(Pattern<? super A> p, Pattern<? super A> q)
      Deprecated.
      Combine two patterns disjunctively.

      A pattern returned by this method is deterministic if and only if both argument patterns are deterministic and mutually exclusive. A pattern returned by this method is ordered if and only if both argument patterns are ordered. It binds all variables bound by both argument patterns.

      Parameters:
      p - an argument pattern
      q - another argument pattern
      Returns:
      a pattern that has a successful match for each successful match of either argument pattern. If both argument patterns are ordered, the resulting order is the concatenation.
    • first

      public static <A> Pattern<Iterable<? extends A>> first(Pattern<? super A> elem)
      Deprecated.
    • somewhere

      public Pattern<Iterable<? extends A>> somewhere()
      Deprecated.
      Return a pattern that attempts to match this pattern successively to all elements of an Iterable.

      A pattern returned by this method is generally nondeterministic. It is ordered if the underlying pattern is ordered. It binds all variables bound by the underlying pattern.

      Returns:
      a pattern that
    • transform

      public <B> Pattern<B> transform(Function<? super B,? extends A> fun)
      Deprecated.
    • forInstancesOf

      public Pattern<Object> forInstancesOf(Class<? extends A> cls)
      Deprecated.