public abstract class NetworkElement extends Object implements Comparable<NetworkElement>
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 |
addTag(String tag)
Adds a tag to this network element.
|
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. |
int |
compareTo(NetworkElement o) |
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, or null if not found.
|
String |
getAttribute(String key,
String defaultValue)
Returns the value of a given attribute for this network element, or the default value provided if not found
|
Double |
getAttributeAsDouble(String key,
Double defaultValue)
Returns the value of a given attribute for this network element
|
List<Double> |
getAttributeAsDoubleList(String key,
List<Double> defaultValue)
Returns the value of a given attribute for this network element, in form of a list of doubles, as stored using the setAttributeAsDoubleList method
|
DoubleMatrix2D |
getAttributeAsDoubleMatrix(String key,
DoubleMatrix2D defaultValue)
Returns the value of a given attribute for this network element, in form of a matrix, as stored using the setAttributeAsDoubleMatrix method
|
List<List<Double>> |
getAttributeAsDoubleMatrix(String key,
List<List<Double>> defaultValue)
Returns the value of a given attribute for this network element, in form of a matrix, as stored using the setAttributeAsDoubleMatrix method
|
List<String> |
getAttributeAsStringList(String key,
List<String> defaultValue)
Returns the value of a given attribute for this network element, in form of a list of strings, as stored using the setAttributeAsStringList method
|
List<List<String>> |
getAttributeAsStringMatrix(String key,
List<List<String>> defaultValue)
Returns the value of a given attribute for this network element, in form of a list of list of strings, as stored using the setAttributeAsStringMatrix method
|
SortedMap<String,String> |
getAttributes()
Returns the element attributes (a copy)
|
String |
getDescription()
Returns current element description String
|
long |
getId()
Returns the unique identifier
|
int |
getIndex()
Returns the index
|
String |
getName()
Returns current element name String
|
NetPlan |
getNetPlan()
Returns the
NetPlan object to which this element is attached |
com.net2plan.internal.Constants.NetworkElementType |
getNeType() |
SortedSet<String> |
getTags()
Returns the set of tags assigned to this network element
|
boolean |
hasTag(String tag)
Returns true if this network element has the given tag
|
void |
removeAllAttributes()
Removes the attribute attached to this network element.
|
void |
removeAttribute(String key)
Removes the attribute attached to this network element.
|
boolean |
removeTag(String tag)
Removes this tag from the network element.
|
void |
setAttribute(String key,
Number value)
Sets an attribute for this element, so it can be read with getAttributeAsNumber method.
|
void |
setAttribute(String key,
String value)
Sets an attribute for this element.
|
void |
setAttributeAsNumberList(String key,
List<? extends Number> valueList)
Sets an attribute for this element, storing the values of the given value list, so it can be read with getAttributeAsNumberList method.
|
void |
setAttributeAsNumberMatrix(String key,
DoubleMatrix2D vals)
Sets an attribute for this element, storing the values of the given matrix, so it can be read with setAttributeAsNumberMatrix method.
|
void |
setAttributeAsNumberMatrix(String key,
List<List<Number>> vals)
Sets an attribute for this element, storing the values of the given matrix, so it can be read with setAttributeAsNumberMatrix method.
|
void |
setAttributeAsStringList(String key,
List<String> vals)
Sets an attribute for this element, storing the values of the given value list, so it can be read with getAttributeAsStringList method.
|
void |
setAttributeAsStringMatrix(String key,
List<List<String>> vals)
Sets an attribute for this element, storing the values of the given value list,
so it can be read with getAttributeAsStringMatrix method.
|
void |
setAttributeMap(Map<String,String> map)
Sets the attributes for this network element.
|
void |
setDescription(String description)
Sets this element description
|
void |
setName(String name)
Sets this element name
|
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 void addTag(String tag)
tag
- the tagpublic 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 int compareTo(NetworkElement o)
compareTo
in interface Comparable<NetworkElement>
public 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
public String getAttribute(String key)
key
- Attribute namenull
, if not defined)public String getAttribute(String key, String defaultValue)
key
- Attribute namedefaultValue
- default value to return if not foundnull
, if not defined)public Double getAttributeAsDouble(String key, Double defaultValue)
key
- Attribute namedefaultValue
- default value to return if not found, or could not be parsedpublic List<Double> getAttributeAsDoubleList(String key, List<Double> defaultValue)
key
- Attribute namedefaultValue
- default value to return if not found, or could not be parsedpublic DoubleMatrix2D getAttributeAsDoubleMatrix(String key, DoubleMatrix2D defaultValue)
key
- Attribute namedefaultValue
- default value to return if not found, or could not be parsedpublic List<List<Double>> getAttributeAsDoubleMatrix(String key, List<List<Double>> defaultValue)
key
- Attribute namedefaultValue
- default value to return if not found, or could not be parsedpublic List<String> getAttributeAsStringList(String key, List<String> defaultValue)
key
- Attribute namedefaultValue
- default value to return if not found, or could not be parsedpublic List<List<String>> getAttributeAsStringMatrix(String key, List<List<String>> defaultValue)
key
- Attribute namedefaultValue
- default value to return if not found, or could not be parsedpublic final SortedMap<String,String> getAttributes()
Returns the element attributes (a copy)
public final String getDescription()
public final long getId()
Returns the unique identifier
public int getIndex()
Returns the index
public final String getName()
public final NetPlan getNetPlan()
Returns the NetPlan
object to which this element is attached
public com.net2plan.internal.Constants.NetworkElementType getNeType()
public SortedSet<String> getTags()
public boolean hasTag(String tag)
tag
- the tagpublic 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 boolean removeTag(String tag)
tag
- the tagpublic void setAttribute(String key, Number value)
Sets an attribute for this element, so it can be read with getAttributeAsNumber method. If it already exists, previous value is lost.
key
- Attribute namevalue
- Attribute valuepublic 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 setAttributeAsNumberList(String key, List<? extends Number> valueList)
key
- Attribute namevalueList
- Attribute valuepublic void setAttributeAsNumberMatrix(String key, DoubleMatrix2D vals)
key
- Attribute namevals
- Attribute valspublic void setAttributeAsNumberMatrix(String key, List<List<Number>> vals)
key
- Attribute namevals
- Attribute valspublic void setAttributeAsStringList(String key, List<String> vals)
key
- Attribute namevals
- Attribute valspublic void setAttributeAsStringMatrix(String key, List<List<String>> vals)
key
- Attribute namevals
- Attribute valspublic 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 final void setDescription(String description)
description
- see abovepublic final void setName(String name)
name
- see abovepublic String toString()
Returns a String
representation of the network element.
public final boolean wasRemoved()
Copyright © 2018. All rights reserved.