Package com.github.moaxcp.graphs
Class AbstractGraph.SimpleEdge
- java.lang.Object
-
- com.github.moaxcp.graphs.AbstractGraph.SimpleEdge
-
- All Implemented Interfaces:
Graph.Edge<ID>
- Direct Known Subclasses:
AbstractEventGraph.EventEdge
- Enclosing class:
- AbstractGraph<ID>
public class AbstractGraph.SimpleEdge extends Object implements Graph.Edge<ID>
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description List<ID>
endpoints()
Returns ordered pair of endpoint ids.boolean
equals(Object o)
ID
from()
Returns vertex id of 'from' endpoint.Graph.Edge<ID>
from(ID from)
Sets vertex id of 'from' endpoint.Graph.Vertex<ID>
fromVertex()
Returns 'from' vertexID
getFrom()
Returns vertex id of 'from' endpoint.Optional<ID>
getId()
Returns optional identifier of this edge.Optional<Object>
getProperty(String name)
Returns the value of a property.ID
getTo()
Returns vertex id of 'to' endpoint.int
hashCode()
Graph.Edge<ID>
id(ID id)
Sets identifier of this edge.Map<String,Object>
inherited()
Returns inherited properties as an unmodifiableMap.boolean
isDirected()
Returns true if this edge is directed.Map<String,Object>
local()
Returns an unmodifiableMap
of all properties set on this Element.SELF
property(String name, Object value)
Adds a local property to this element returning it.Graph.Edge<ID>
removeProperty(String name)
Removes local propertyvoid
setFrom(ID from)
Sets vertex id of 'from' endpoint.void
setId(ID id)
Sets identifier of this edge.void
setProperty(String name, Object value)
Adds a local property to this element.void
setTo(ID to)
Sets vertex id of 'to' endpoint.ID
to()
Returns vertex id of 'to' endpoint.Graph.Edge<ID>
to(ID to)
Sets vertex id of 'to' endpoint.Graph.Vertex<ID>
toVertex()
Returns 'to' vertex-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.github.moaxcp.graphs.Graph.Edge
getProperty, inherited, local, property
-
-
-
-
Method Detail
-
getId
public final Optional<ID> getId()
Description copied from interface:Graph.Edge
Returns optional identifier of this edge.- Specified by:
getId
in interfaceGraph.Edge<ID>
- Returns:
- optional identifier
-
setId
public void setId(ID id)
Description copied from interface:Graph.Edge
Sets identifier of this edge.- Specified by:
setId
in interfaceGraph.Edge<ID>
- Parameters:
id
- of edge
-
id
public final Graph.Edge<ID> id(ID id)
Description copied from interface:Graph.Edge
Sets identifier of this edge.- Specified by:
id
in interfaceGraph.Edge<ID>
- Parameters:
id
- of edge- Returns:
- this edge
-
getFrom
public final ID getFrom()
Description copied from interface:Graph.Edge
Returns vertex id of 'from' endpoint.- Specified by:
getFrom
in interfaceGraph.Edge<ID>
- Returns:
- id of 'from' endpoint
-
setFrom
public void setFrom(ID from)
Description copied from interface:Graph.Edge
Sets vertex id of 'from' endpoint. If vertex does not exist it is created.- Specified by:
setFrom
in interfaceGraph.Edge<ID>
- Parameters:
from
- endpoint
-
from
public Graph.Edge<ID> from(ID from)
Description copied from interface:Graph.Edge
Sets vertex id of 'from' endpoint. If vertex does not exist it is created.- Specified by:
from
in interfaceGraph.Edge<ID>
- Parameters:
from
- endpoint- Returns:
- this edge
-
from
public final ID from()
Description copied from interface:Graph.Edge
Returns vertex id of 'from' endpoint.- Specified by:
from
in interfaceGraph.Edge<ID>
- Returns:
- id of 'from' endpoint
-
getTo
public final ID getTo()
Description copied from interface:Graph.Edge
Returns vertex id of 'to' endpoint.- Specified by:
getTo
in interfaceGraph.Edge<ID>
- Returns:
- id of 'to' endpoint
-
setTo
public void setTo(ID to)
Description copied from interface:Graph.Edge
Sets vertex id of 'to' endpoint. If vertex does not exist it is created.- Specified by:
setTo
in interfaceGraph.Edge<ID>
- Parameters:
to
- endpoint
-
to
public final Graph.Edge<ID> to(ID to)
Description copied from interface:Graph.Edge
Sets vertex id of 'to' endpoint. If vertex does not exist it is created.- Specified by:
to
in interfaceGraph.Edge<ID>
- Parameters:
to
- endpoint- Returns:
- this edge
-
to
public final ID to()
Description copied from interface:Graph.Edge
Returns vertex id of 'to' endpoint.- Specified by:
to
in interfaceGraph.Edge<ID>
- Returns:
- id of 'to' endpoint
-
isDirected
public final boolean isDirected()
Description copied from interface:Graph.Edge
Returns true if this edge is directed. This edge is always directed if the parent graph is directed.- Specified by:
isDirected
in interfaceGraph.Edge<ID>
- Returns:
- true if this edge is directed
-
endpoints
public final List<ID> endpoints()
Description copied from interface:Graph.Edge
Returns ordered pair of endpoint ids. 'from' endpoint id is always first followed by 'to' endpoint id.- Specified by:
endpoints
in interfaceGraph.Edge<ID>
- Returns:
- order pair of endpoints
-
fromVertex
public final Graph.Vertex<ID> fromVertex()
Description copied from interface:Graph.Edge
Returns 'from' vertex- Specified by:
fromVertex
in interfaceGraph.Edge<ID>
- Returns:
- 'from' vertex
-
toVertex
public final Graph.Vertex<ID> toVertex()
Description copied from interface:Graph.Edge
Returns 'to' vertex- Specified by:
toVertex
in interfaceGraph.Edge<ID>
- Returns:
- 'to' vertex
-
setProperty
public void setProperty(String name, Object value)
Adds a local property to this element.- Specified by:
setProperty
in interfaceGraph.Edge<ID>
- Parameters:
name
- of propertyvalue
- of property
-
removeProperty
public Graph.Edge<ID> removeProperty(String name)
Removes local property- Specified by:
removeProperty
in interfaceGraph.Edge<ID>
- Parameters:
name
- of property- Returns:
- this element
-
inherited
public final Map<String,Object> inherited()
Returns inherited properties as an unmodifiableMap.- Returns:
- inherited properties
-
local
public final Map<String,Object> local()
Returns an unmodifiableMap
of all properties set on this Element.- Returns:
- all properties set on this element
-
getProperty
public final Optional<Object> getProperty(String name)
Returns the value of a property. If the property is local its value is returned before checking for an inherited property.- Parameters:
name
- of property to return- Returns:
- value mapped to name
- Throws:
NullPointerException
- if name is null
-
-