Merge branch 'master' of ../controller
[yangtools.git] / yang / yang-data-jaxen / src / main / java / org / opendaylight / yangtools / yang / data / jaxen / Operator.java
1 /*
2  * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.yangtools.yang.data.jaxen;
9
10 enum Operator {
11     EQUALS,
12     NOT_EQUALS,
13     GREATER_THAN,
14     GREATER_THAN_EQUALS,
15     LESS_THAN,
16     LESS_THAN_EQUALS,
17     MINUS,
18     PLUS,
19     AND,
20     OR,
21     DIV,
22     MOD,
23     MULTIPLY,
24     UNION;
25
26     static Operator forString(final String str) {
27         switch (str) {
28             case "=":
29                 return Operator.EQUALS;
30             case "!=":
31                 return Operator.NOT_EQUALS;
32             case "-":
33                 return Operator.MINUS;
34             case "+":
35                 return Operator.PLUS;
36             case "and":
37                 return Operator.AND;
38             case "or":
39                 return Operator.OR;
40             case "div":
41                 return Operator.DIV;
42             case "mod":
43                 return Operator.MOD;
44             case "*":
45                 return Operator.MULTIPLY;
46             case ">=":
47                 return Operator.GREATER_THAN_EQUALS;
48             case ">":
49                 return Operator.GREATER_THAN;
50             case "<=":
51                 return Operator.LESS_THAN_EQUALS;
52             case "<":
53                 return Operator.LESS_THAN;
54             case "|":
55                 return Operator.UNION;
56             default:
57                 throw new IllegalArgumentException("Unknown operator " + str);
58
59         }
60     }
61 }