Interface IdBuilder<K>
-
- 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.
@FunctionalInterface public interface IdBuilder<K>
Builder for unique identifiers of vertices or edges in a graph.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, seeGraph.addEdge(Object, Object, Object)
andGraph.addEdge(Object, Object)
. The graph expose its vertex and edge builders usingGraph.vertexBuilder()
andGraph.edgeBuilder()
, which may returnnull
. 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
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description K
build(Set<K> existing)
Builds 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.static <K> Supplier<IdBuilder<K>>
defaultFactory(Class<K> idType)
Get an default factory for identifiers of the given type.
-
-
-
Method Detail
-
build
K build(Set<K> existing)
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
static <K> IdBuilder<K> defaultBuilder(Class<K> idType)
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
static <K> Supplier<IdBuilder<K>> defaultFactory(Class<K> idType)
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
-
-