BrightSide Workbench Full Report + Source Code
ParserParameter.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2020 Lluis TurrĂ³ Cutiller <http://www.turro.org/>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Affero General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Affero General Public License for more details.
14  *
15  * You should have received a copy of the GNU Affero General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 package org.turro.parser;
20 
21 import java.util.HashSet;
22 import org.turro.util.CompareUtil;
23 
28 public class ParserParameter implements Comparable<ParserParameter> {
29 
30  protected String name;
31  protected boolean optional;
32  protected int order;
33  protected boolean commaSeparated;
34  protected HashSet<String> possibleValues = new HashSet<>();
35  protected String defaultValue;
36 
37  public ParserParameter(String name, boolean optional, String defaultValue, int order) {
38  this(name, optional, defaultValue, order, false);
39  }
40 
41  public ParserParameter(String name, boolean optional, String defaultValue, int order, boolean commaSeparated) {
42  this.name = name;
43  this.optional = optional;
44  this.defaultValue = defaultValue;
45  this.order = order;
46  this.commaSeparated = commaSeparated;
47  }
48 
49  public String getName() {
50  return name;
51  }
52 
53  public boolean isOptional() {
54  return optional;
55  }
56 
57  public String getDefaultValue() {
58  return defaultValue;
59  }
60 
61  public int getOrder() {
62  return order;
63  }
64 
65  public boolean isCommaSeparated() {
66  return commaSeparated;
67  }
68 
69  public HashSet<String> getPossibleValues() {
70  return possibleValues;
71  }
72 
73  public void addPossibleValue(String value) {
74  possibleValues.add(value);
75  }
76 
77  @Override
78  public int compareTo(ParserParameter o) {
79  int result = CompareUtil.compare(order, o.order);
80  if(result == 0) {
81  result = CompareUtil.compare(name, o.name);
82  }
83  if(result == 0) {
84  result = CompareUtil.compare(optional, o.optional);
85  }
86  return result;
87  }
88 
89 }
int compareTo(ParserParameter o)
HashSet< String > getPossibleValues()
ParserParameter(String name, boolean optional, String defaultValue, int order, boolean commaSeparated)
ParserParameter(String name, boolean optional, String defaultValue, int order)