-
Notifications
You must be signed in to change notification settings - Fork 2
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
Conversation
…ce/target methods won't work (now wee need to bind all parameters 👎)
This is more or less ready as a proof-of-the-concept. |
Some summary of what we have with this approach. Actually, this version is not less verbose than what we have from #57:
This approach has its advantages and disadvantages:
|
|
|
||
return vertexType.fromRaw( | ||
return vertexType.new Vertex( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@eparejatobes take a look, please. If I use .fromRaw
here, I get
com.bio4j.angulillos.VertexType.Vertex cannot be converted to
com.bio4j.angulillos.VertexType.Vertex
😆
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess you need VT extends G.VertexType<...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At this moment there is no G.VertexType
yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, there is something funny happening. I've tried changing that many times and sometimes I cannot get rid of these errors, but then if I clean
(well) and compile, it compiles fine. I just tried to make a little snippet of code with the same pattern and I couldn't reproduce this compilation error, so I think that it's some incremental compilation artefacts..
…out the SuppressWarnings annotation
…dge to the corresponding classes; TypedGraph is empty now
@@ -14,8 +14,9 @@ | |||
|
|||
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(); |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
I was looking for some information about self-reference pattern in Java and I found this SO answer plus some other places, where people write that the bound on the self-type parameter class Foo<F extends Foo<F>> is an illusion of safety and does not enforce F to be self-reference. I still can write public final class Tweet extends VertexType<User> {
@Override public User self() { return user; }
...
} P.S. this just means that we cannot refer to the self-type in the abstract code when using something specific about its instance. So I'll just write |
Yup, http://stackoverflow.com/a/14755312/614394 It's not exactly the same with mutually recursive parameters, though. |
About the warnings: my somewhat cryptic (writing from my phone) comment #58 (comment) tried to imply that for that you'd need to make everything inner classes. If so, it should probably work. |
…in the TypedGraph
|
…); changed self() to protected; made Vertex inner class non-final
Good news @eparejatobes!!! We don't have to change anything related to the inner-classes. I was about to fall asleep when I suddenly realised that the problem in the above mentioned example is in the misuse of the types there. First, there is G extends TwitterSchema<RV,RE> then protected G g; and then I was trying to create a user-vertex: // This warns about unchecked conversion:
TwitterSchema<RV,RE>.User.Vertex tu = g.user.addVertex();
// This is correct:
G.User.Vertex gu = g.user.addVertex();
// This won't compile:
VertexType<G.User, G,RV,RE>.Vertex gu2 = g.user.addVertex();
// Neither this:
G.VertexType<G.User>.Vertex gu3 = g.user.addVertex(); I think that the warning message is just very confusing, showing as the "found" type |
…ethod to add them to this set
…ically added there once instantiated)
… to define a propety/vertex type with an existing label, on the graph instantiation you will get an exception)
@laughedelic but then you'd need to add suppress warnings to all methods, basically because we cannot know that |
Replaced by #62 |
No description provided.