1 package rydeen;
2
3 import java.io.Serializable;
4
5
6
7
8
9
10
11
12 public class ArgumentImpl implements Serializable, Argument{
13 private static final long serialVersionUID = 5126931208339916608L;
14
15 private String name;
16 private String value;
17 private String description;
18
19
20
21
22
23 public ArgumentImpl(Argument arg){
24 this(arg.getName(), arg.getValue(), arg.getDescription());
25 }
26
27
28
29
30
31
32
33 public ArgumentImpl(String name){
34 this(name, null, null);
35 }
36
37
38
39
40
41
42
43
44 public ArgumentImpl(String name, String value){
45 this(name, value, null);
46 }
47
48
49
50
51
52
53
54
55
56 public ArgumentImpl(String name, String value, String description){
57 if(name == null){
58 throw new NullPointerException();
59 }
60 this.name = name;
61 setValue(value);
62 setDescription(description);
63 }
64
65
66
67
68
69 @Override
70 public String getName(){
71 return name;
72 }
73
74
75
76
77
78 @Override
79 public String getValue(){
80 return value;
81 }
82
83
84
85
86
87 public void setValue(String value){
88 this.value = value;
89 }
90
91
92
93
94
95 @Override
96 public String getDescription(){
97 return description;
98 }
99
100
101
102
103 public void setDescription(String description){
104 this.description = description;
105 }
106
107
108
109
110 @Override
111 public String toString(){
112 StringBuilder sb = new StringBuilder();
113 sb.append(getName()).append("=");
114 if(getValue() == null){
115 sb.append("<null>");
116 }
117 else{
118 sb.append(getValue());
119 }
120 if(getDescription() != null){
121 sb.append("(").append(description).append(")");
122 }
123 return new String(sb);
124 }
125 }