I tried to implement this in Java, and it went through without problems and remained unsatisfied with By (). You probably have some problems in your implementation, here's mine:
public boolean isSpecialCaseOf(Specification spec) { if (spec instanceof GreaterThan) { return ((GreaterThan) spec).boundary > this.boundary; } return false; }
The trap is in the Not () method, which should correctly construct the opposite type of argument.
static final Specification Not(Specification spec) { return spec.not(); }
Then I only need to have the correct implementation of not () for each specification, for example. for LesserThan:
@Override public Specification not() { return new GreaterThan(boundary); }
If you have any problems, please provide your implementation of GreatherThan.isSpecialCaseOf and not, I will try to help.
source share