private Pointcut removeNothings(Pointcut pc) {
if (isAnd(pc)) {
AndPointcut apc = (AndPointcut)pc;
Pointcut right = removeNothings(apc.getRight());
Pointcut left = removeNothings(apc.getLeft());
if (left instanceof MatchesNothingPointcut || right instanceof MatchesNothingPointcut) return new MatchesNothingPointcut();
return new AndPointcut(left,right);
} else if (isOr(pc)) {
OrPointcut opc = (OrPointcut)pc;
Pointcut right = removeNothings(opc.getRight());
Pointcut left = removeNothings(opc.getLeft());
if (left instanceof MatchesNothingPointcut
&& !(right instanceof MatchesNothingPointcut)) {
return right;
} else if (right instanceof MatchesNothingPointcut
&& !(left instanceof MatchesNothingPointcut)) {
return left;
} else if (!(left instanceof MatchesNothingPointcut)
&& !(right instanceof MatchesNothingPointcut)) {
return new OrPointcut(left,right);
} else if (left instanceof MatchesNothingPointcut
&& right instanceof MatchesNothingPointcut) {
return new MatchesNothingPointcut();
}
}
return pc;
}