Right now, the only Collection available in the
Composition relationship is List. However I would like
to use more general interface, to provide better
hermetization. After changing the Composition member
type from List to Collection, green UML ceases to
recognize it as a Composition.
Logged In: YES
user_id=862234
Hi!
This is a result of the way we defined the semantics of the
composition relationship. We will look at changing this,
because we have noticed this behavior too. The issue is
that the semantics are set up so recognize exactly what it
generates, which is of necessity a concrete Collection
class. We need to revisit the semantic definition for this
relationship to determine how easy or hard this change might be.
Just so you know, the relationships are defined each in
their own plugin. If you want to play with tweaking the
relationship semantics yourself, you can download the source
code and redefine the three visitors on the JDT abstract
syntax tree that together give the semantics of a
relationship (one each for recognition, generation and removal).
We'll update this tracker thread once we've looked in more
detail at the semantics of composition. (BTW, this probably
affects association as well.)
Logged In: YES
user_id=1605409
Hmm... I suppose it is so. And, as far as I am concerned,
the relation requires me to instantiate the class in
constructor. Of course, a generic HashMap isn't concerned to
be a composition,as well.
I would love to tinker with that, but I hardly got time for
my own stuff. However if I do anything about that, I will
immediatly let you know.
Logged In: YES
user_id=1231978
Originator: NO
To Green team: As far as recognition goes, you can you the isAssignableFrom(...) method to check whether the class implements the Collection interface. For example:
Collection.class.isAssignableFrom(List.class)
Will return true. Provided that you can resolve the class, this should be useful.
You could also use the method newSupertypeHierarchy(...) in IType and check to see whether collection is a supertype. This might be easier.
For generation of collections, see ChooseTypeWizard. You could allow the user to select both the declared and actual types. It might be best, though, to set this as a preference after you've implemented the feature. For example, you could set a "default declared type" and "default actual type" and have an option to allow the user to automatically use those every time (by checking a check box).
@alphonce
This isn't a matter of individual relationship semantics. The relationship recognizer is looking for a specific declared type (see edu.buffalo.cse.green.relationships.RelationshipGenerator.LIST). You're right - it affects composition as well.
Logged In: YES
user_id=1231978
Originator: NO
At this point, this is a dupe. Either close it or close all the dupes of it.