View Javadoc
1   package net.sumaris.core.extraction.vo;
2   
3   /*-
4    * #%L
5    * SUMARiS:: Core
6    * %%
7    * Copyright (C) 2018 SUMARiS Consortium
8    * %%
9    * This program is free software: you can redistribute it and/or modify
10   * it under the terms of the GNU General Public License as
11   * published by the Free Software Foundation, either version 3 of the
12   * License, or (at your option) any later version.
13   * 
14   * This program is distributed in the hope that it will be useful,
15   * but WITHOUT ANY WARRANTY; without even the implied warranty of
16   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17   * GNU General Public License for more details.
18   * 
19   * You should have received a copy of the GNU General Public
20   * License along with this program.  If not, see
21   * <http://www.gnu.org/licenses/gpl-3.0.html>.
22   * #L%
23   */
24  
25  import com.google.common.base.Preconditions;
26  
27  import java.util.Arrays;
28  
29  public enum ExtractionFilterOperatorEnum {
30  
31      IN("IN"),
32      NOT_IN("NOT IN"),
33      EQUALS("="),
34      NOT_EQUALS("!="),
35      GREATER_THAN(">"),
36      GREATER_THAN_OR_EQUALS(">="),
37      LESS_THAN("<"),
38      LESS_THAN_OR_EQUALS("<="),
39      BETWEEN("BETWEEN");
40  
41      private String symbol;
42  
43      ExtractionFilterOperatorEnum(String symbol) {
44          this.symbol = symbol;
45      }
46  
47      public String getSymbol() {
48          return symbol;
49      }
50  
51      public static ExtractionFilterOperatorEnum fromSymbol(String operator) {
52          Preconditions.checkNotNull(operator);
53          return Arrays.stream(values())
54                  .filter(op -> op.symbol.equalsIgnoreCase(operator))
55                  .findFirst()
56                  .orElseThrow(() -> new IllegalArgumentException("Unknown operation symbol"));
57      }
58  
59  
60  }