Closed laughedelic closed 8 years ago
@eparejatobes please, take a look :pray:
After all my suffering in #58 and #60 and experimenting with things in #61 and some other branches that don't worth to be pushed here, I can say that what I have here is the best option I can get (again, I was trying really hard, you know :neutral_face:).
Using inner classes as in #58 doesn't help to simplify the API and it has a major disadvantage: it's hard to override methods in them. I'm even not sure if it's possible to do in any reasonable way, because if you subclass and have a more precise User.Vertex
type, all its non-overriden API methods still return the type of the inner class from its parent.
Therefore I think it's better to use inner classes only on the level of the schema definition (i.e. VertexType
/EdgeType
inside of a TypedGraph
/GraphSchema
).
Putting all things in one file doesn't help anything, see https://github.com/bio4j/angulillos/pull/60#issuecomment-205377558.
So, what we have here:
self()
thing)Vertex
/Edge
class, or its concrete instanceIf you are fine with this approach, I will cherry-pick good things from #58, especially the auto-schema-related stuff from #59.
We can already try this with some Bio4j graph. The Titan implementation should work (modulo the schema creation).
UPD: currently angulillos-titan compiles without any changes.
@laughedelic I'm going to look at this tonight/tomorrow morning.
What I'm working on here:
UntypedGraph
interface to use Any
-types instead of stringsinEdges
/outEdges
sets to the AnyVertexType interfaceI'm merging and releasing it as v0.7.0
I've already started some changes in master accidentally. Starting from what we had before the #58:
Vertex
andVertexType
:User
as a uniqueVertexType
and then have its "value type" asVertex<User>
Vertex
(because we are going to refer to this as a type) and also have a value reference to itsVertexType
which only needs to have afromRaw
factory method returning a value of thatUser
typeVertexType
is that we would normally store properties in it and refer to them asg.user.name
,g.posted.date
.We can add properties as the members of the
User
value-type and add setter/getter methods, then the syntax for working with them would change fromto
which doesn't look too bad and is more concise than the old one. Btw, I've tried to make them instances of
Supplier<X>
(for the.get()
method) andFunction<V,X>
(for.apply()
) hoping that it will allow for syntax likebob.name("Bob")
instead ofbob.name.apply("Bob")
, but it seems that Java doesn't have any shortcuts "( :-1:The schema definition becomes much more clear than before and almost doesn't have boilerplate code:
No any significant changes to the inner code needed. Only the
GraphSchema
class.