carnival-data / carnival

JVM property graph data unification framework
https://carnival-data.github.io/carnival/
GNU General Public License v3.0
7 stars 2 forks source link

MethodsHolder look up class heirarchy for method classes #51

Closed augustearth closed 3 years ago

augustearth commented 3 years ago

See carnival-core/src/test/groovy/carnival/core/util/MethodsHolderSpec.groovy. Without this change, we cannot extend GraphMethods classes add new methods or functionality, which could be useful.

For example, there could be an abstract GraphMethods class that contains a set of standardized methods to interact with a resource and also has an abstract method getServerUrl() that points to that resource. Concrete sub-classes could get the server URL from a configuration utility without having to re-implement the GraphMethod classes.

It would be nice to be able to inherit from GraphMethods classes.

augustearth commented 3 years ago

Will implement this so that inner classes cannot be overridden. So, we will not be able to do:

class JvsTestVine implements Vine { 

    @ToString(includeNames=true)
    static class Person { String name }

    class PersonVineMethod extends JsonVineMethod<Person> { 
        Person fetch(Map args) { new Person(name:args.p1) }
    }

}

class JvsTestVineWithResource extends JvsTestVine { 

    String sharedResource = 'blah-'

    class PersonVineMethod extends JsonVineMethod<JvsTestVine.Person> { 
        JvsTestVine.Person fetch(Map args) { 
            String name = "" + sharedResource + args.p1
            new JvsTestVine.Person(name:name) 
        }
    }

}

Because PersonVineMethod is shared. This is a design choice.... we could let child classes "override" parent ones. Maybe we will decide to do that later.

augustearth commented 3 years ago

Closed by 26ffc2d7b6be6e009b5fa2c807c46dd4d3677da9