k3 icon indicating copy to clipboard operation
k3 copied to clipboard

Determine which collection types have to be supported

Open tdegueul opened this issue 11 years ago • 0 comments

In K3, one may want to write this kind of code:

class A {
    // @Opposite...
    // @Composition...
    List<B> myB
}

In such a case, the annotations inject specific semantic on the collection behavior. Thus, in order to use myB, the client must use specific methods (e.g. A.addMyB(B)) that are dynamically added by the annotation processors in the generated Java code. This generated code must handle the specific semantic of the annotations, plus general tasks such as the initialization of the collection. For this purpose, we need to know the concrete type of the collection.

OCL uses 4 types of collection: Sequence, Set, OrderedSet and Bag. Should K3 handle the same types? (or Java equivalents)

Also, it could be handy to allow the developer to simply declare a collection without worrying about the implementation details (as in a model), and provide simple annotations to specify it's semantic:

class A {
    @Unique
    @Ordered
    Collection<B> myB    // Real type will be OrderedSet
}

tdegueul avatar Oct 18 '13 13:10 tdegueul