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

Classes all the way down #58

Closed
wants to merge 21 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
eb12cce
WIP: rewriting everything with inner classes
laughedelic Mar 26, 2016
bbec14a
Added source and target graphs to the edge parameters; otherwise sour…
laughedelic Mar 27, 2016
758be84
Returning VT.Vertex-like types; using .new Vertex() for that; .fromRa…
laughedelic Mar 28, 2016
e9bb8a1
Cleaned build well, now .fromRaw() works as expected; added a note ab…
laughedelic Mar 28, 2016
fbbaffd
Added arity-specific methods in/out-E/V methods with default implemen…
laughedelic Mar 28, 2016
7bb50cf
Moved all in/out methods from graph to Vertex class
laughedelic Mar 28, 2016
23ebbf0
Moved source/target, all propeties-related methods and addVertex/addE…
laughedelic Mar 28, 2016
f17a4e7
Just moved things from GraphSchema to TypedGraph (now it's one class)
laughedelic Mar 28, 2016
1a8b15a
Made top-level classes public, renamed files
laughedelic Mar 29, 2016
a41459e
Added TypedLinkGraph (not the best name, but will work for now)
laughedelic Mar 29, 2016
86b6145
Updated tests code; discovered that .fromRaw() doesn't return the exp…
laughedelic Mar 29, 2016
0f3f829
Rewrote index-related code; added two classes refining the interface …
laughedelic Mar 29, 2016
f9dc524
Made top-level entities explicitly public
laughedelic Mar 29, 2016
3226993
Added methods for all members instead of fields (except of the _label…
laughedelic Mar 30, 2016
604ddad
Added to ElementType properties set and made the properties factory m…
laughedelic Mar 30, 2016
d83494e
Added a set containing all vertex types of a graph (which are automat…
laughedelic Mar 30, 2016
0a8be61
Added a check on the set construction for distinct labels (if you try…
laughedelic Mar 30, 2016
e89f450
Added inner class Property to the ElementType
laughedelic Mar 30, 2016
6635419
Added UntypedGraphSchema interface for schema creation; separated tra…
laughedelic Mar 30, 2016
e3b59ae
Added sets for holding all graph's edge types and indexes
laughedelic Mar 30, 2016
94012e6
Merge branch 'feature/schema-creation' into refactoring/everything-is…
laughedelic Mar 30, 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
1 change: 0 additions & 1 deletion src/main/java/com/bio4j/angulillos/EdgeType.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ protected EdgeType(ST sourceType, TT targetType) {
/* This method adds a new edge of this type to the graph */
public ET.Edge addEdge(
VertexType<ST, SG,RV,RE>.Vertex source,
ET edgeType,
VertexType<TT, TG,RV,RE>.Vertex target
) {
return fromRaw(
Expand Down
31 changes: 14 additions & 17 deletions src/test/java/com/bio4j/angulillos/TwitterGraphTestSuite.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,27 @@ public abstract class TwitterGraphTestSuite<

public TwitterSchema<RV,RE>.User.Vertex addUser(String name, Integer age) {

return g.addVertex(g.user)
.set(g.user.name, name)
TwitterSchema<RV,RE>.User.Vertex u = g.user.addVertex();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eparejatobes
In the end I think we still need to write VertexType<VT, ...>.Vertex instead of just VT.Vertex in the abstract code. because on this line I get

[warn] /Users/laughedelic/dev/bio4j/angulillos/src/test/java/com/bio4j/angulillos/TwitterGraphTestSuite.java:17: unchecked conversion
[warn]   required: com.bio4j.angulillos.VertexType<com.bio4j.angulillos.TwitterSchema<RV,RE>.User,com.bio4j.angulillos.TwitterSchema<RV,RE>,RV,RE>.Vertex
[warn]   found:    com.bio4j.angulillos.VertexType.Vertex
[warn]     TwitterSchema<RV,RE>.User.Vertex u = g.user.addVertex();

and it means that the VT.Vertex addVertex() signature is interpreted as VertexType.Vertex addVertex(), because at that moment everything the compiler know is that VT <: VertexType (without params).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, but then how are we gettting the right type? through calling the right constructor once an schema has been implemented?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The thing is that VertexType<VT, ...>.Vertex is the right type, once VT is fixed. Look at the "expected" type in the warning message. I can write

// VT.Vertex
TwitterSchema<RV,RE>.User.Vertex u1 = null; // just to have something of this type

// VertexType<VT, G,RV,RE>.Vertex
VertexType<
  TwitterSchema<RV,RE>.User, 
  TwitterSchema<RV,RE>, 
  RV,RE
>.Vertex u2 = u1;

and another way round. And there won't be any warnings about unchecked conversions.


return u.set(g.user.name, name)
.set(g.user.age, age);
}

public void doSomething(TwitterSchema<RV,RE>.User.Vertex user) {

System.out.println(user.get(g.user.age));

TwitterSchema<RV,RE>.User.Vertex bob = addUser("Bob", 25);

TwitterSchema<RV,RE>.Follows.Edge edge =
g.addEdge(
bob,
g.follows,
addUser("Alice", 34)
);

Stream<TwitterSchema<RV,RE>.Follows.Edge> followEdges = bob.outE(g.follows);
Stream<TwitterSchema<RV,RE>.Tweet.Vertex> tweets = user.outV(g.posted);
Stream<TwitterSchema<RV,RE>.User.Vertex> followees = bob.outV(g.follows);

// TwitterSchema<RV,RE>.User.Vertex source = g.source(edge);
TwitterSchema<RV,RE>.User.Vertex source = edge.source();
// TwitterSchema<RV,RE>.User.Vertex bob = addUser("Bob", 25);
//
// TwitterSchema<RV,RE>.Follows.Edge edge =
// g.follows.addEdge( bob, addUser("Alice", 34) );
//
// Stream<TwitterSchema<RV,RE>.Follows.Edge> followEdges = bob.outE(g.follows);
// Stream<TwitterSchema<RV,RE>.Tweet.Vertex> tweets = user.outV(g.posted);
// Stream<TwitterSchema<RV,RE>.User.Vertex> followees = bob.outV(g.follows);
//
// // TwitterSchema<RV,RE>.User.Vertex source = g.source(edge);
// TwitterSchema<RV,RE>.User.Vertex source = edge.source();
}

// public Stream<TwitterSchema<RV,RE>.User> tweetedTheTweetsThatTweeted(TwitterSchema<RV,RE>.User user) {
Expand Down
14 changes: 3 additions & 11 deletions src/test/java/com/bio4j/angulillos/TwitterSchema.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

public class TwitterSchema<RV,RE>
extends
GraphSchema<TwitterSchema<RV,RE>, RV,RE>
TypedGraph<TwitterSchema<RV,RE>, RV,RE>
{

public final TwitterSchema<RV,RE> self() { return this; }
Expand Down Expand Up @@ -37,11 +37,7 @@ public final class Tweet extends VertexType<Tweet> {
/* ### Edges and their types */

public final Follows follows = new Follows();
public final class Follows extends EdgeType<
User, TwitterSchema<RV,RE>,
Follows,
User, TwitterSchema<RV,RE>
>
public final class Follows extends EdgeType<User, Follows, User>
implements AnyToAny {
@Override public Follows self() { return this; }
Follows() { super(user, user); }
Expand All @@ -51,11 +47,7 @@ public final class Follows extends EdgeType<

// Any tweet is posted by exactly one user, but user may post any number of tweets (incl. 0)
public final Posted posted = new Posted();
public final class Posted extends EdgeType<
User, TwitterSchema<RV,RE>,
Posted,
Tweet, TwitterSchema<RV,RE>
>
public final class Posted extends EdgeType<User, Posted, Tweet>
implements OneToAny {
@Override public Posted self() { return this; }
Posted() { super(user, tweet); }
Expand Down