com.bpodgursky.jbool_expressions.rules.SimplifyNot Maven / Gradle / Ivy
package com.bpodgursky.jbool_expressions.rules;
import com.bpodgursky.jbool_expressions.Expression;
import com.bpodgursky.jbool_expressions.Literal;
import com.bpodgursky.jbool_expressions.Not;
public class SimplifyNot extends Rule, K> {
@Override
public Expression applyInternal(Not input) {
Expression e = input.getE();
if(e instanceof Literal){
Literal l = (Literal) e;
return Literal.of(!l.getValue());
}
if(e instanceof Not){
Not internal = (Not) e;
return internal.getE();
}
return input;
}
@Override
protected boolean isApply(Expression input) {
return input instanceof Not;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy