1 package org.opentrafficsim.simulationengine.properties;
2
3
4
5
6
7
8
9
10
11
12
13 public class BooleanProperty extends AbstractProperty<Boolean>
14 {
15
16 private Boolean value;
17
18
19 private String shortName;
20
21
22 private String description;
23
24
25 private final Boolean readOnly;
26
27
28
29
30
31
32
33
34
35 public BooleanProperty(final String shortName, final String description, final Boolean initialValue,
36 final boolean readOnly, final int displayPriority)
37 {
38 super(displayPriority);
39 this.shortName = shortName;
40 this.description = description;
41 this.value = initialValue;
42 this.readOnly = readOnly;
43 }
44
45
46 @Override
47 public final Boolean getValue()
48 {
49 return this.value;
50 }
51
52
53 @Override
54 public final String getShortName()
55 {
56 return this.shortName;
57 }
58
59
60 @Override
61 public final String getDescription()
62 {
63 return this.description;
64 }
65
66
67 @Override
68 public final void setValue(final Boolean newValue) throws PropertyException
69 {
70 if (this.readOnly)
71 {
72 throw new PropertyException("This property is read-only");
73 }
74 this.value = newValue;
75 }
76
77
78 @Override
79 public final boolean isReadOnly()
80 {
81 return this.readOnly;
82 }
83
84
85 @Override
86 public final String htmlStateDescription()
87 {
88 return getShortName() + ": " + (null == this.value ? "null" : this.value ? "true" : "false");
89 }
90
91
92 @Override
93 public AbstractProperty<Boolean> deepCopy()
94 {
95 return new BooleanProperty(this.shortName, this.description, this.value, this.readOnly, this.getDisplayPriority());
96 }
97
98 }