org.snapscript.tree.condition.ConditionalOperator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of snap Show documentation
Show all versions of snap Show documentation
Dynamic scripting for the JVM
package org.snapscript.tree.condition;
import org.snapscript.parse.StringToken;
public enum ConditionalOperator {
AND("&&"),
OR("||");
private final String operator;
private ConditionalOperator(String operator){
this.operator = operator;
}
public boolean isAnd() {
return this == AND;
}
public boolean isOr() {
return this == OR;
}
public static ConditionalOperator resolveOperator(StringToken token){
if(token != null) {
String value = token.getValue();
for(ConditionalOperator operator : VALUES) {
if(operator.operator.equals(value)) {
return operator;
}
}
}
return null;
}
private static final ConditionalOperator[] VALUES = {
AND,
OR
};
}