*TL;DR*We can use Java generics to represent the left half of the above ER
diagram

*Context*
In this mail I am talking about the Java API not the entity model itself. I
am not yet fully convinced about this dual hierarchy model. I feel like the
version stuff should be a 'diff' form the point of view of the composer
API, and the "Type" (eg: Service) and "TypeVersion" (eg: Service Version)
should be homogeneous form the point of view of the consumer API. But this
mail is not about that.

*Suggestion*
Since the entity relationship is duplicated, it would be more elegant to
only repentant half of it as a Java class hierarchy. As we discussed, all
the descendants of "Base" will have similar attributes. Therefor we can
model them as a generic class that is the type parametrized on the Version
descendant.

*Limitations*
This will not work if each base type has different attributes.

*Code Sample*

//  Type class below maps to Base entity and all it's descendants in
the ER diagrampublic class Type<T> {

    public T getDefault() {
    }

    public static <M> Type<M> getTypeOf(M t) {
    }}
//  Service class below maps to "Service Version" entity in the ER diagram
Service defaultSibling = Type.getTypeOf(myService).getDefault();

-- 
With regards,
*Manu*ranga Perera.

phone : 071 7 70 20 50
mail : [email protected]
_______________________________________________
Architecture mailing list
[email protected]
https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture

Reply via email to