Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't use properties through the element values #62

Merged
merged 30 commits into from
May 10, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
df02607
Moved properties from types to the elements; now types don't need to …
laughedelic Apr 4, 2016
b77da70
Experimenting with the overrides on the level of a particular graph s…
laughedelic Apr 4, 2016
f598a89
Added arity-specific methods in/out-E/V methods with default implemen…
laughedelic Mar 28, 2016
c296eda
Made top-level interfaces/classes public; put the test in another pac…
laughedelic Apr 4, 2016
3b58628
Put Arity outside of the edge type
laughedelic Apr 4, 2016
536c3de
Moved all the methods from TypedGraph to the elements interfaces
laughedelic Apr 4, 2016
15e47fa
Moved things from GraphSchema to the TypedGraph, made it a class
laughedelic Apr 4, 2016
69ee46d
Removed unused imports
laughedelic Apr 4, 2016
2d50894
Removed unused self() from the ElementType, other minor cleanups
laughedelic Apr 4, 2016
b3171a4
general code review
eparejatobes Apr 7, 2016
e7f0168
Changed everything to have moar tasty boilerplate, bringing more unif…
laughedelic Apr 23, 2016
1d568d6
Merge branch 'experiment/properties-in-elements' of https://github.co…
laughedelic Apr 23, 2016
53a70cd
Made Property an interface which the inner class implements
laughedelic Apr 23, 2016
5c2707f
Split Arity on two: From/To; Added FromArity to Property
laughedelic Apr 23, 2016
5944d47
Added Unique and NonUnique Property types to fix the arity
laughedelic Apr 23, 2016
9422e89
Added vertex types list to the typed graph
laughedelic Apr 27, 2016
9a32e57
Added edges types list to the typed graph
laughedelic Apr 27, 2016
24f0d5a
Added properties list to the typed element
laughedelic Apr 27, 2016
b8f4c2f
Added self to (nonabstract) Twitter graph; added simple test for the …
laughedelic Apr 27, 2016
c36a074
Added UntypedGraphSchema interface for schema creation; separated tra…
laughedelic Mar 30, 2016
36b8e52
WIP: rewriting schema creation methods
laughedelic May 5, 2016
5265136
* Added common HasLabel interface
laughedelic May 5, 2016
f471196
Renamed files to make Any-traits public (probably will change later)
laughedelic May 6, 2016
0296a75
make tests compile
eparejatobes May 10, 2016
6e1cbd7
Added inEdges/outEdges sets to the AnyVertexType interface filled on …
laughedelic May 10, 2016
de35722
Added some code to for printing schema in the console
laughedelic May 10, 2016
5a56fb6
Merge branch 'experiment/properties-in-elements' of https://github.co…
laughedelic May 10, 2016
254d2e8
Changed UntypedGraph interface to use Any-types instead of strings
laughedelic May 10, 2016
129ec04
Fixed createSchema name
laughedelic May 10, 2016
ba2f17d
Renamed ...Label parameters to ...Type
laughedelic May 10, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 98 additions & 0 deletions src/main/java/com/bio4j/angulillos/AnyEdgeType.java
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();
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.bio4j.angulillos;

import java.util.Set;

/*
## Elements

Expand All @@ -13,6 +15,12 @@

`E` refers to the element itself, and `ET` its type. You cannot define one without defining the other.
*/
public interface AnyElementType extends HasLabel {

AnyTypedGraph graph();
Set<AnyProperty> properties();
}

interface TypedElement <
F extends TypedElement<F,FT, G,RF>,
FT extends TypedElement.Type<F,FT, G,RF>,
Expand All @@ -31,12 +39,11 @@ interface Type <
FT extends TypedElement.Type<F,FT, G,RF>,
G extends TypedGraph<G,?,?>,
RF
> {
> extends AnyElementType {
public G graph();

/* Constructs a value of the typed element of this type */
F fromRaw(RF rawElem);

// NOTE: this should be final, but interface cannot have final methods
default String _label() { return getClass().getCanonicalName(); }
}


Expand All @@ -50,7 +57,7 @@ interface Type <
RF raw();

/* The graph in which this element lives. */
G graph();
default G graph() { return type().graph(); }

/* The `get` method lets you get the value of a `property` which this element has. For that, you pass as an argument the [property](Property.java.md). Note that the type bounds only allow properties of this element. */
<X> X get(Property<FT,X> property);
Expand Down
24 changes: 24 additions & 0 deletions src/main/java/com/bio4j/angulillos/AnyProperty.java
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();
}
Loading