-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'experiment/properties-in-elements' (#62)
- Loading branch information
Showing
20 changed files
with
713 additions
and
723 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
package com.bio4j.angulillos; | ||
|
||
/* | ||
## Edges | ||
A typed edge with explicit source and target. | ||
- `S` the source TypedVertex, `ST` the source TypedVertex type | ||
- `E` the edge, `ET` the edge type | ||
- `T` the target TypedVertex, `TT` the target TypedVertex type | ||
*/ | ||
public interface AnyEdgeType extends | ||
AnyElementType, | ||
HasFromArity, | ||
HasToArity | ||
{ | ||
|
||
AnyVertexType sourceType(); | ||
AnyVertexType targetType(); | ||
} | ||
|
||
// TODO: make it public | ||
interface TypedEdge < | ||
// source vertex | ||
S extends TypedVertex<S,ST, ?,RV,RE>, | ||
ST extends TypedVertex.Type<S,ST, ?,RV,RE>, | ||
// edge | ||
E extends TypedEdge<S,ST, E,ET, T,TT, G,RV,RE>, | ||
ET extends TypedEdge.Type<S,ST, E,ET, T,TT, G,RV,RE>, | ||
// target vertex | ||
T extends TypedVertex<T,TT, ?,RV,RE>, | ||
TT extends TypedVertex.Type<T,TT, ?,RV,RE>, | ||
// graph & raws | ||
G extends TypedGraph<G,RV,RE>, | ||
RV,RE | ||
> | ||
extends TypedElement<E,ET,G,RE> | ||
{ | ||
|
||
interface Type < | ||
// source vertex | ||
S extends TypedVertex<S,ST, ?,RV,RE>, | ||
ST extends TypedVertex.Type<S,ST, ?,RV,RE>, | ||
// edge | ||
E extends TypedEdge<S,ST, E,ET, T,TT, G,RV,RE>, | ||
ET extends TypedEdge.Type<S,ST, E,ET, T,TT, G,RV,RE>, | ||
// target vertex | ||
T extends TypedVertex<T,TT, ?,RV,RE>, | ||
TT extends TypedVertex.Type<T,TT, ?,RV,RE>, | ||
// graph & raws | ||
G extends TypedGraph<G,RV,RE>, | ||
RV,RE | ||
> extends | ||
TypedElement.Type<E,ET,G,RE>, | ||
AnyEdgeType | ||
{ | ||
ST sourceType(); | ||
TT targetType(); | ||
|
||
/* adds an edge; note that this method does not set any properties. As it needs to be called by vertices in possibly different graphs, all the graph bounds are free with respect to G. */ | ||
default E addEdge(S from, T to) { | ||
|
||
return this.fromRaw( | ||
graph().raw().addEdge( from.raw(), this, to.raw() ) | ||
); | ||
} | ||
|
||
} | ||
|
||
|
||
/* the source vertex of this edge */ | ||
default S source() { | ||
return type().sourceType().fromRaw( | ||
graph().raw().source( raw() ) | ||
); | ||
} | ||
|
||
/* the target vertex of this edge */ | ||
default T target() { | ||
return type().targetType().fromRaw( | ||
graph().raw().target( raw() ) | ||
); | ||
} | ||
|
||
|
||
@Override default | ||
<X> X get(Property<ET,X> property) { | ||
return graph().raw().<X>getPropertyE(raw(), property); | ||
} | ||
|
||
@Override default | ||
<X> E set(Property<ET,X> property, X value) { | ||
|
||
graph().raw().setPropertyE(raw(), property, value); | ||
return self(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.bio4j.angulillos; | ||
|
||
/* | ||
## Properties | ||
A property of the [Element](TypedElement.java.md) of type `FT`, with value type `X`. | ||
*/ | ||
public interface AnyProperty extends | ||
HasLabel, | ||
HasFromArity { | ||
|
||
AnyElementType elementType(); | ||
Class<?> valueClass(); | ||
} | ||
|
||
// TODO: make it public | ||
interface Property< | ||
FT extends TypedElement.Type<?,FT,?,?>, | ||
X | ||
> extends AnyProperty { | ||
|
||
FT elementType(); | ||
Class<X> valueClass(); | ||
} |
Oops, something went wrong.