271237271644c1a3fb1bb3a8b51bb2f80ab66198
[openflowplugin.git] / openflow-codec / src / main / java / org / openflow / codec / example / cli / Option.java
1 package org.openflow.codec.example.cli;
2
3 public class Option {
4     String shortOpt;
5     String longOpt;
6     Object defaultVal;
7     String val; // current value of this option, string form
8     boolean specified; // was this option found in the cmdline?
9     String comment;
10
11     /**
12      * Option information storrage
13      *
14      * @param shortOpt
15      *            Short name for the option, e.g., "-p"
16      * @param longOpt
17      *            Long name for option, e.g., "--port"
18      * @param defaultVal
19      *            default value: "6633" or null if no default value
20      * @param comment
21      *            String to print to explain this option, e.g., a help message
22      */
23     public Option(String shortOpt, String longOpt, Object defaultVal, String comment) {
24         super();
25         this.shortOpt = shortOpt;
26         this.longOpt = longOpt;
27         this.defaultVal = defaultVal;
28         this.comment = comment;
29         this.specified = false;
30     }
31
32     public Option(String shortOpt, String longOpt, String comment) {
33         this(shortOpt, longOpt, null, comment);
34     }
35
36     public boolean needsArg() {
37         return this.defaultVal != null;
38     }
39 }