69 lines
1.9 KiB
Java
69 lines
1.9 KiB
Java
package org.gcube.informationsystem.resourceregistry.queries.operators;
|
|
|
|
import java.util.HashMap;
|
|
import java.util.HashSet;
|
|
import java.util.Map;
|
|
import java.util.Set;
|
|
|
|
/**
|
|
* @author Luca Frosini (ISTI - CNR)
|
|
* See https://www.orientdb.com/docs/3.0.x/sql/SQL-Where.html
|
|
*/
|
|
public enum MatemathicsOperator {
|
|
|
|
SUM("_sum", " + ", ""),
|
|
MINUS("_minus", " - ", ""),
|
|
MULTIPLY("_multiply", " * ", ""),
|
|
DIVIDE("_divide", " / ", ""),
|
|
MODULE("_mod", " % ", ""),
|
|
BITWISE_RIGHT_SHIFT("_bitrshift", " >> ", ""),
|
|
BITWISE_LEFT_SHIFT("_bitlshift", " << ", ""),
|
|
BITWISE_AND("_bitand", " & ", ""),
|
|
BITWISE_OR("_bitor", " | ", ""),
|
|
BITWISE_XOR("_bitxor", " ^ ", ""),
|
|
ARRAY_CONCATENATION("_arrayconcat", " || ", "");
|
|
|
|
protected final String operator;
|
|
protected final String matemathicsOperator;
|
|
protected final String description;
|
|
|
|
private MatemathicsOperator(String operator, String matemathicsOperator, String description) {
|
|
this.operator = operator;
|
|
this.matemathicsOperator = matemathicsOperator;
|
|
this.description = description;
|
|
}
|
|
|
|
public String getOperator() {
|
|
return operator;
|
|
}
|
|
|
|
public String getMatemathicsOperator() {
|
|
return matemathicsOperator;
|
|
}
|
|
|
|
public String getDescription() {
|
|
return description;
|
|
}
|
|
|
|
private static Set<String> operators;
|
|
private static Map<String,MatemathicsOperator> operatorByKey;
|
|
|
|
static {
|
|
MatemathicsOperator.operators = new HashSet<>();
|
|
MatemathicsOperator.operatorByKey = new HashMap<>();
|
|
|
|
for(MatemathicsOperator queryLogicalOperator : MatemathicsOperator.values()) {
|
|
MatemathicsOperator.operators.add(queryLogicalOperator.getOperator());
|
|
MatemathicsOperator.operatorByKey.put(queryLogicalOperator.getOperator(), queryLogicalOperator);
|
|
}
|
|
}
|
|
|
|
public static Set<String> getOperators() {
|
|
return MatemathicsOperator.operators;
|
|
}
|
|
|
|
public static MatemathicsOperator getQueryLogicalOperator(String key) {
|
|
return operatorByKey.get(key);
|
|
}
|
|
}
|