@@ -16,6 +16,10 @@ interface AnyTypedGraph {
1616
1717 Set<AnyVertexType > vertexTypes ();
1818 Set<AnyEdgeType > edgeTypes ();
19+ Set<TypedVertexIndex .Unique<?,?,?,?,?,?> > uniqueVertexIndexes ();
20+ Set<TypedVertexIndex .NonUnique<?,?,?,?,?,?> > nonUniqueVertexIndexes ();
21+ Set<TypedEdgeIndex .Unique<?,?,?,?,?,?> > uniqueEdgeIndexes ();
22+ Set<TypedEdgeIndex .NonUnique<?,?,?,?,?,?> > nonUniqueEdgeIndexes ();
1923}
2024
2125public abstract class TypedGraph <
@@ -43,6 +47,18 @@ This set will store all edge types defined for this graph
4347```java
4448 private final Set<AnyEdgeType > edgeTypes = new java.util.HashSet<> ();
4549 public final Set<AnyEdgeType > edgeTypes () { return this . edgeTypes; }
50+
51+ private final Set<TypedVertexIndex .Unique<?,?,?,?,?,?> > uniqueVertexIndexes = new java.util.HashSet<> ();
52+ public final Set<TypedVertexIndex .Unique<?,?,?,?,?,?> > uniqueVertexIndexes () { return this . uniqueVertexIndexes; }
53+
54+ private final Set<TypedVertexIndex .NonUnique<?,?,?,?,?,?> > nonUniqueVertexIndexes = new java.util.HashSet<> ();
55+ public final Set<TypedVertexIndex .NonUnique<?,?,?,?,?,?> > nonUniqueVertexIndexes () { return this . nonUniqueVertexIndexes; }
56+
57+ private final Set<TypedEdgeIndex .Unique<?,?,?,?,?,?> > uniqueEdgeIndexes = new java.util.HashSet<> ();
58+ public final Set<TypedEdgeIndex .Unique<?,?,?,?,?,?> > uniqueEdgeIndexes () { return this . uniqueEdgeIndexes; }
59+
60+ private final Set<TypedEdgeIndex .NonUnique<?,?,?,?,?,?> > nonUniqueEdgeIndexes = new java.util.HashSet<> ();
61+ public final Set<TypedEdgeIndex .NonUnique<?,?,?,?,?,?> > nonUniqueEdgeIndexes () { return this . nonUniqueEdgeIndexes; }
4662```
4763
4864### Abstract helper classes
@@ -121,7 +137,6 @@ This set stores all properties that are defined on this element type
121137 }
122138 }
123139
124-
125140 public abstract class Vertex <
126141 V extends Vertex<V >
127142 > extends Element<V , VertexType<V > , RV >
@@ -154,8 +169,61 @@ This set stores all properties that are defined on this element type
154169 }
155170 TypedGraph . this . vertexTypes. add( self() );
156171 }
157- }
158172
173+ public class UniqueIndex <
174+ P extends Property<X > & Arity .FromAtMostOne ,
175+ X
176+ >
177+ implements TypedVertexIndex .Unique<V ,VertexType<V > ,P ,X ,RV ,RE > {
178+
179+ private final P property;
180+ public final P property () { return property; }
181+
182+ protected UniqueIndex (P property ) { this . property = property; }
183+
184+ {
185+ if (
186+ TypedGraph . this . uniqueVertexIndexes. removeIf(
187+ vt - > vt. _label(). equals( _label() )
188+ )
189+ )
190+ {
191+ throw new IllegalArgumentException (" The graph contains a duplicate index type: " + _label());
192+ }
193+ else {
194+
195+ TypedGraph . this . uniqueVertexIndexes. add( this );
196+ }
197+ }
198+ }
199+
200+ public class NonUniqueIndex <
201+ P extends Property<X > ,
202+ X
203+ >
204+ implements TypedVertexIndex .NonUnique<V ,VertexType<V > ,P ,X ,RV ,RE > {
205+
206+ private final P property;
207+ public final P property () { return property; }
208+
209+ protected NonUniqueIndex (P property ) { this . property = property; }
210+
211+ {
212+ if (
213+ TypedGraph . this . nonUniqueVertexIndexes. removeIf(
214+ vt - > vt. _label(). equals( _label() )
215+ )
216+ )
217+ {
218+ throw new IllegalArgumentException (" The graph contains a duplicate index type: " + _label());
219+ }
220+ else {
221+
222+ TypedGraph . this . nonUniqueVertexIndexes. add( this );
223+ }
224+ }
225+ }
226+ }
159227
160228 public abstract class Edge <
161229 S extends Vertex<S > ,
@@ -182,7 +250,9 @@ This set stores all properties that are defined on this element type
182250 E , EdgeType<S ,E ,T > ,
183251 T , VertexType<T > ,
184252 G ,RV ,RE
185- > {
253+ >
254+ {
255+
186256 protected EdgeType<S ,E ,T > self () { return this ; }
187257
188258 private final VertexType<S > sourceType;
@@ -212,6 +282,60 @@ This set stores all properties that are defined on this element type
212282 sourceType. outEdges. add( self() );
213283 targetType. inEdges. add( self() );
214284 }
285+
286+ public class UniqueIndex <
287+ P extends Property<X > & Arity .FromAtMostOne ,
288+ X
289+ >
290+ implements com.bio4j.angulillos. TypedEdgeIndex .Unique<E ,EdgeType<S ,E ,T > ,P ,X ,RV ,RE > {
291+
292+ private final P property;
293+ public final P property () { return property; }
294+
295+ protected UniqueIndex (P property ) { this . property = property; }
296+
297+ {
298+ if (
299+ TypedGraph . this . uniqueEdgeIndexes. removeIf(
300+ vt - > vt. _label(). equals( _label() )
301+ )
302+ )
303+ {
304+ throw new IllegalArgumentException (" The graph contains a duplicate index type: " + _label());
305+ }
306+ else {
307+
308+ TypedGraph . this . uniqueEdgeIndexes. add( this );
309+ }
310+ }
311+ }
312+
313+ public class NonUniqueIndex <
314+ P extends Property<X > ,
315+ X
316+ >
317+ implements com.bio4j.angulillos. TypedEdgeIndex .NonUnique<E ,EdgeType<S ,E ,T > ,P ,X ,RV ,RE > {
318+
319+ private final P property;
320+ public final P property () { return property; }
321+
322+ protected NonUniqueIndex (P property ) { this . property = property; }
323+
324+ {
325+ if (
326+ TypedGraph . this . nonUniqueEdgeIndexes. removeIf(
327+ vt - > vt. _label(). equals( _label() )
328+ )
329+ )
330+ {
331+ throw new IllegalArgumentException (" The graph contains a duplicate index type: " + _label());
332+ }
333+ else {
334+
335+ TypedGraph . this . nonUniqueEdgeIndexes. add( this );
336+ }
337+ }
338+ }
215339 }
216340}
217341
0 commit comments