View Javadoc

1   /*
2    * This file is part of hyphenType. hyphenType is free software: you can
3    * redistribute it and/or modify it under the terms of the GNU General Public
4    * License as published by the Free Software Foundation, either version 3 of the
5    * License, or (at your option) any later version. hyphenType is distributed in
6    * the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
7    * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
8    * the GNU General Public License for more details. You should have received a
9    * copy of the GNU General Public License along with hyphenType. If not, see
10   * <http://www.gnu.org/licenses/>.
11   */
12  package org.hyphenType.datastructure.parser.option;
13  
14  import java.lang.reflect.Method;
15  import java.util.Collections;
16  import java.util.List;
17  
18  import org.hyphenType.datastructure.parser.StructureElement;
19  
20  /**
21   * @author Aurelio Akira M. Matsui
22   */
23  public class StructureOption extends StructureElement implements Comparable<StructureOption> {
24  
25      public final String description;
26      public final List<String> alternatives;
27      public final StructureOptionValue value;
28      public final StructureOptionMapValue map;
29      public final List<StructureOptionArgument> arguments;
30  
31      public StructureOption(Method method, String description, List<String> alternatives, StructureOptionValue value, StructureOptionMapValue map, List<StructureOptionArgument> arguments) {
32          super(method);
33          this.description = description;
34          this.alternatives = Collections.unmodifiableList(alternatives);
35          this.value = value;
36          this.map = map;
37          this.arguments = Collections.unmodifiableList(arguments);
38      }
39  
40      @Override
41      public String toString() {
42          return "[alternatives = " + alternatives + ",  method = " + method + ", value = " + value + " ]";
43      }
44  
45      @Override
46      public boolean equals(Object obj) {
47          if (!(obj instanceof StructureOption))
48              return false;
49          StructureOption other = (StructureOption) obj;
50          return other.method.equals(this.method);
51      }
52  
53      @Override
54      public int hashCode() {
55          return method.hashCode();
56      }
57  
58      @Override
59      public int compareTo(StructureOption o) {
60          return this.toString().compareTo(o.toString());
61      }
62  }