-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathNamedExternalEvent.java
More file actions
83 lines (73 loc) · 2.45 KB
/
NamedExternalEvent.java
File metadata and controls
83 lines (73 loc) · 2.45 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
package cambio.simulator.entities;
import cambio.simulator.models.MiSimModel;
import desmoj.core.simulator.ExternalEvent;
/**
* Class that adds further options for the retrieving of names of {@link ExternalEvent}s. Specifically, it provides a
* plain name for each event, that does not contain the number assigned by DESMO-J. However, these plain names are not
* guaranteed to be unique.
*
* <p>
* Also pre-computes the names of the entity so the strings are not generated on every method call. This gives a
* performance improvement over the default implementation when read a large amount of names.
* </p>
*
* <p>
* Plain names should be used when it comes to generating new entity names based on other entity names to prevent chains
* of unique identifiers.
*
* @author Lion Wagner
*/
public abstract class NamedExternalEvent extends ExternalEvent {
private final MiSimModel model;
private String plainName;
private String quotedName;
private String quotedPlainName;
/**
* Constructs a new named event.
*
* @param model The model this event belongs to.
* @param name The name of this event.
* @param showInTrace Flag indicating whether the entity should be shown in the trace.
*/
public NamedExternalEvent(MiSimModel model, String name, boolean showInTrace) {
super(model, name, showInTrace);
this.plainName = name;
this.quotedPlainName = "'" + name + "'";
this.quotedName = super.getQuotedName();
this.model = model;
}
public String getPlainName() {
return this.plainName;
}
/**
* Renames this entity.
*/
@Override
public void rename(String name) {
super.rename(name);
this.plainName = name;
this.quotedPlainName = "'" + name + "'";
this.quotedName = super.getQuotedName();
}
/**
* Gets a quoted version of the plain name of this object.
*
* @return the plain name of this entity surrounded with ' quotes.
*/
public String getQuotedPlainName() {
return this.quotedPlainName;
}
/**
* Gets a quoted version of the name of this object. The name will include the object number assigned by DESMO-J.
*
* @return the name of this entity surrounded with ' quotes.
*/
@Override
public String getQuotedName() {
return this.quotedName;
}
@Override
public MiSimModel getModel() {
return this.model;
}
}