-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathSString.java
More file actions
107 lines (97 loc) · 2.19 KB
/
Copy pathSString.java
File metadata and controls
107 lines (97 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
package sysmlinjava.valuetypes;
import sysmlinjava.annotations.Attribute;
import sysmlinjava.units.SysMLinJavaUnits;
/**
* SysMLinJava value type for the SysML String implemented with a standard Java
* String.
* <p>
* Note that the {@code String} name clashes with the {@code java.lang.String}
* name. Therefore, this SysMLinJava version uses the double S spelling.
* <p>
*
* @author ModelerOne
*
*/
public class SString extends SysMLValueType
{
/**
* Attribute for the value of the string as a java String type
*/
@Attribute
public String value;
/**
* Constructor
*
* @param value java string to be used as initial value
*/
public SString(String value)
{
super();
this.value = value;
}
/**
* Constructor - copied
*
* @param copied instance to be used for initial value of copuy
*/
public SString(SString copied)
{
super(copied);
this.value = copied.value;
}
/**
* Returns the java string value of this instance
*
* @return value as a java string
*/
public String getValue()
{
return value;
}
/**
* Sets this value to the specified java value
*
* @param value java string value to be set as this value
*/
public void setValue(String value)
{
this.value = value;
notifyValueChangeObservers();
}
@Override
public boolean equals(Object obj)
{
if (obj instanceof SString)
return value.equals(((SString)obj).value);
else
return false;
}
/**
* Returns new instance that is value of the specified java string
*
* @param string java string value used as initial value of new instance
* @return new instance that is value of the specified java string
*/
public static SString valueOf(String string)
{
return new SString(string);
}
@Override
protected void createUnits()
{
units = SysMLinJavaUnits.Characters;
}
@Override
public String toString()
{
StringBuilder builder = new StringBuilder();
builder.append("SString [value=");
builder.append(value);
builder.append(", name=");
builder.append(name);
builder.append(", id=");
builder.append(id);
builder.append("]");
return builder.toString();
}
}