Interface IdBuilder<K>
- Type Parameters:
K
- the type of identifiers (vertices/edges)
- All Known Subinterfaces:
IdBuilderInt
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
A Graph
allows adding vertices by either providing an identifier (Graph.addVertex(Object)
) or without
(Graph.addVertex()
). If no identifier is provided, the graph will generate one using an instance of this
interface. The same is true for edges, see Graph.addEdge(Object, Object, Object)
and
Graph.addEdge(Object, Object)
. The graph expose its vertex and edge builders using
Graph.vertexBuilder()
and Graph.edgeBuilder()
, which may return null
. The identifiers
returned by this interface must be unique in the graph.
This interface is shared for both vertices and edges, but an instance of this interface is used only for one of them at a time.
- Author:
- Barak Ugav
-
Method Summary
Modifier and TypeMethodDescriptionBuilds a unique identifier for a vertex or an edge.static <K> IdBuilder
<K> defaultBuilder
(Class<K> idType) Get an default builder for identifiers of the given type.defaultFactory
(Class<K> idType) Get an default factory for identifiers of the given type.
-
Method Details
-
build
Builds a unique identifier for a vertex or an edge.- Parameters:
existing
- the identifiers of the vertices or edges already in the graph- Returns:
- a unique identifier
-
defaultBuilder
Get an default builder for identifiers of the given type.A default builder existing for the following types:
byte
andByte
short
andShort
int
andInteger
long
andLong
float
andFloat
double
andDouble
String
- any other type that has a public constructor with no arguments
Object.equals(Object)
method.The returned builder may be passed to
GraphFactory.setVertexBuilder(IdBuilder)
.- Type Parameters:
K
- the type of the identifiers- Parameters:
idType
- the id type class- Returns:
- a default builder for identifiers of
idType
- Throws:
IllegalArgumentException
- if the type is not supported
-
defaultFactory
Get an default factory for identifiers of the given type.A default factory existing for the following types:
byte
andByte
short
andShort
int
andInteger
long
andLong
float
andFloat
double
andDouble
String
- any other type that has a public constructor with no arguments
Object.equals(Object)
method.The returned factory may be passed to
GraphFactory.setVertexFactory(Supplier)
.- Type Parameters:
K
- the type of the identifiers- Parameters:
idType
- the id type class- Returns:
- a default factory for identifiers of
idType
- Throws:
IllegalArgumentException
- if the type is not supported
-