commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Carman" <ja...@carmanconsulting.com>
Subject [FUNCTOR] Does functor have a class for this?
Date Thu, 18 Mar 2004 14:17:46 GMT
I want to turn a BinaryPredicate into a Predicate by using Functions for the
left/right operands to the BinaryPredicate.

 

public class BinaryPredicateToPredicate implements Predicate

{

  private final Function leftFunction;

  private final Function rightFunction;

  private final BinaryPredicate binaryPredicate;

 

  public BinaryPredicateToPredicate( BinaryPredicate binaryPredicate,
Function leftFunction, Function rightPredicate )

  {

    this.leftFunction = leftFunction;

    this.rightFunction = rightFunction;

    this.binaryPredicate = binaryPredicate;

  }

 

  public boolean test()

  {

    binaryPredicate.test( leftFunction.evaluate(), rightFunction.evaluate()
);

  }

}

 

Does the functor library already have something for this?

 


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message