Class Offset

java.lang.Object
org.apache.commons.functor.core.Offset
All Implemented Interfaces:
BinaryFunctor<Object,Object>, BinaryPredicate<Object,Object>, Functor, NullaryFunctor, Predicate, UnaryFunctor<Object>, UnaryPredicate<Object>

public final class Offset extends Object implements Predicate, UnaryPredicate<Object>, BinaryPredicate<Object,Object>
A predicate that returns false the first n times it is invoked, and true thereafter.
Since:
1.0
Version:
$Revision$ $Date$
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private int
    The current number of times the predicate has been invoked.
    private final int
    The number of times the predicate must return false.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Offset(int count)
    Create a new Offset.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Evaluate this predicate.
    boolean
    test(Object obj)
    Evaluate this predicate.
    boolean
    Evaluate this predicate.
    Returns a human readable description of this functor.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface Functor

    equals, hashCode
  • Field Details

    • min

      private final int min
      The number of times the predicate must return false.
    • current

      private int current
      The current number of times the predicate has been invoked.
  • Constructor Details

    • Offset

      public Offset(int count)
      Create a new Offset.
      Parameters:
      count - offset
  • Method Details

    • test

      public boolean test()
      Evaluate this predicate.
      Specified by:
      test in interface Predicate
      Returns:
      the result of this test
    • test

      public boolean test(Object obj)
      Evaluate this predicate.
      Specified by:
      test in interface UnaryPredicate<Object>
      Parameters:
      obj - the A object to test
      Returns:
      the result of this test
    • test

      public boolean test(Object a, Object b)
      Evaluate this predicate.
      Specified by:
      test in interface BinaryPredicate<Object,Object>
      Parameters:
      a - the L element of the ordered pair of arguments
      b - the R element of the ordered pair of arguments
      Returns:
      the result of this test for the given arguments
    • toString

      public String toString()
      Returns a human readable description of this functor. Implementators are strongly encouraged but not strictly required to override the default Object implementation of this method.
      Specified by:
      toString in interface Functor
      Overrides:
      toString in class Object
      Returns:
      a human readable description of this functor