All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.snapscript.tree.condition.ConditionalOperator Maven / Gradle / Ivy

There is a newer version: 1.4.6
Show newest version
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
  };
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy