
com.bpodgursky.jbool_expressions.And Maven / Gradle / Ivy
package com.bpodgursky.jbool_expressions;
import org.apache.commons.lang.StringUtils;
import java.util.List;
public class And extends NExpression {
public static final String EXPR_TYPE = "and";
private And(List> children) {
super(children);
}
@Override
protected Expression createInternal(List> children) {
return new And(children);
}
public String toString(){
return "("+ StringUtils.join(expressions, " & ")+")";
}
public static And of(Expression child1, Expression child2, Expression child3){
return of(ExprUtil.list(child1, child2, child3));
}
public static And of(Expression child1, Expression child2){
return of(ExprUtil.list(child1, child2));
}
public static And of(Expression child1){
return of(ExprUtil.list(child1));
}
public static And of(List> children){
return new And(children);
}
@Override
public boolean equals(Expression expr) {
if(!(expr instanceof And)){
return false;
}
And other = (And) expr;
if(other.expressions.length != expressions.length){
return false;
}
for(int i = 0; i < expressions.length; i++){
if(!expressions[i].equals(other.expressions[i])){
return false;
}
}
return true;
}
@Override
public String getExprType() {
return EXPR_TYPE;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy