public class NetworkElement
extends Object
Class defining a generic network element.
This class represents a network element. It contains bare minimum fields and methods to be considered the skeleton for other network elements wich extends this class; such as nodes, links, demands, etc.
Modifier and Type | Method and Description |
---|---|
void |
checkAttachedToNetPlanObject()
Checks whether this element (demand, node, route...) is attached to a netPlan object.
|
void |
checkAttachedToNetPlanObject(NetPlan np)
Checks whether this element (demand, node, route...) was not already removed from the
NetPlan object. |
boolean |
equals(Object o)
Return true if the Object o is an IdetifiedElement, with the same identifier and attached to the same NetPlan object
|
String |
getAttribute(String key)
Returns the value of a given attribute for this network element.
|
Map<String,String> |
getAttributes()
Returns the element attributes (a copy)
|
long |
getId()
Returns the unique identifier
|
int |
getIndex()
Returns the index
|
NetPlan |
getNetPlan()
Returns the
NetPlan object to which this element is attached |
void |
removeAllAttributes()
Removes the attribute attached to this network element.
|
void |
removeAttribute(String key)
Removes the attribute attached to this network element.
|
void |
setAttribute(String key,
String value)
Sets an attribute for this element.
|
void |
setAttributeMap(Map<String,String> map)
Sets the attributes for this network element.
|
String |
toString()
Returns a
String representation of the network element. |
boolean |
wasRemoved()
Return true if the element was already removed from the NetPlan object, and thus cannot be acccessed
|
public final void checkAttachedToNetPlanObject()
Checks whether this element (demand, node, route...) is attached to a netPlan object. When negative, an exception will be thrown.
public final void checkAttachedToNetPlanObject(NetPlan np)
Checks whether this element (demand, node, route...) was not already removed from the NetPlan
object. When negative, an exception will be thrown.
np
- NetPlan objectpublic final boolean equals(Object o)
Return true if the Object o is an IdetifiedElement, with the same identifier and attached to the same NetPlan object
equals
in class Object
o
- Object to compare topublic String getAttribute(String key)
Returns the value of a given attribute for this network element. If not defined, the attribute is searched in the netPlan object this element is attached to. Then, it returns null if the attribute is not found also there
key
- Attribute namenull
, if not defined)public final Map<String,String> getAttributes()
Returns the element attributes (a copy)
public final long getId()
Returns the unique identifier
public int getIndex()
Returns the index
public final NetPlan getNetPlan()
Returns the NetPlan
object to which this element is attached
public final void removeAllAttributes()
Removes the attribute attached to this network element. If the attribute does not exist in this network element, no action is made
public final void removeAttribute(String key)
key
- Attribute namepublic void setAttribute(String key, String value)
Sets an attribute for this element. If it already exists, it will be overriden.
key
- Attribute namevalue
- Attribute valuepublic void setAttributeMap(Map<String,String> map)
Sets the attributes for this network element. Any previous attributes will be removed.
map
- Attribute where the keys are the attribute names and the values the attribute valuespublic String toString()
Returns a String
representation of the network element.
toString
in class Object
String
representation of the network elementpublic final boolean wasRemoved()