public class Entity extends java.lang.Object implements Named, java.lang.Comparable<Entity>
A generic entity that can be used as a Customer, a Job, etc. It can be subclassed to add features or properties, or additional properties can be added dynamically.
Entity has been made "Comparable" so that it can easily be put into sorted containers, such as a TreeSet. The default ordering is by the timeStamp property, with ties broken by the id property. There is some danger to this because the timeStamp property is mutable, and therefore bad things could happen if it were modified on an instance while it was in a sorted container. Therefore, care must be taken so that the stampTime() method is only invoked when the instance is not in a sorted container. Usually there will not be a need to do this, but if it is absolutely necessary, then the instance should first be removed from the container, then stampTime() invoked, and finally the instance put back on the container.
Modifier and Type | Field and Description |
---|---|
private double |
creationTime |
static java.lang.String |
DEFAULT_NAME |
private BasicEventList |
eventList |
private int |
id |
private java.lang.String |
name |
private static java.util.concurrent.atomic.AtomicInteger |
NEXT_ID |
private java.util.LinkedHashMap<java.lang.String,java.lang.Object> |
properties |
private double |
timeStamp |
Constructor and Description |
---|
Entity()
Instantiate an Entity with the default name.
|
Entity(java.lang.String name)
Instantiate an Entity with the given name.
|
Modifier and Type | Method and Description |
---|---|
int |
compareTo(Entity o)
Higher priority is based on timeStamp property, with ties broken by id
property.
|
double |
getAge() |
double |
getCreationTime() |
double |
getElapsedTime() |
BasicEventList |
getEventList() |
int |
getID() |
java.lang.String |
getName() |
java.util.LinkedHashMap<java.lang.String,java.lang.Object> |
getProperties() |
java.lang.Object |
getProperty(java.lang.String name) |
double |
getTimeStamp() |
java.lang.String |
paramString() |
void |
setEventList(BasicEventList eventList) |
void |
setEventListID(int eventListID) |
void |
setName(java.lang.String name) |
void |
setProperty(java.lang.String name,
java.lang.Object value)
Add a new property with the given name and value.
|
void |
stampTime()
Set timeStamp to the current simTime
|
java.lang.String |
toString() |
public static final java.lang.String DEFAULT_NAME
private static final java.util.concurrent.atomic.AtomicInteger NEXT_ID
private int id
private double creationTime
private double timeStamp
private java.util.LinkedHashMap<java.lang.String,java.lang.Object> properties
private java.lang.String name
private BasicEventList eventList
public Entity(java.lang.String name)
name
- The name of this Entitypublic Entity()
public void stampTime()
public double getAge()
public double getElapsedTime()
public void setProperty(java.lang.String name, java.lang.Object value)
name
- the name of the propertyvalue
- the value of the propertypublic java.lang.Object getProperty(java.lang.String name)
name
- the name of the desired propertypublic double getCreationTime()
public double getTimeStamp()
public java.util.LinkedHashMap<java.lang.String,java.lang.Object> getProperties()
public java.lang.String getName()
public void setName(java.lang.String name)
public int getID()
public BasicEventList getEventList()
public void setEventList(BasicEventList eventList)
eventList
- the eventList to setpublic void setEventListID(int eventListID)
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String paramString()
public int compareTo(Entity o)
compareTo
in interface java.lang.Comparable<Entity>
o
- Entity to be compared with