You don't need to extend existing UML metaclass to create new type. In UML metamodel, it is defined that an attribute (a Property
) is linked to a Type
by the reference type
. A Type
that can be attached to a property can be an Inteface/Class/PrimitiveType...
instance. Actually, part of the UML basic types are just PrimitiveType
instances defined in an other model which is imported (look for packageImport
in your UML model XMI).
When you set the type of a Property
to Integer
, you set the type of your Property
instance to the PrimitiveType
instance named Integer
. So if you want a HashMap
type, you just have to create an instance of PrimitiveType
named HashMap
(as you have done) and that's all.
However, as you are "binding" your model to Java, I suspect that you will probably want to model generic types (HashMap<String, Integer>
for example). To do that, you will have to handle UML templates.
http://www.uml-diagrams.org/template.html
In that case, you will have to create a templateable Class
with two formal parameters named HashMap
and to bind it in order to produce the bound type. Then, you will be able to use the bound type as type for a Property
instance (no need for UML metamodel extension either).
Note:
PrimitiveType
is a UML metaclass. You can extend it using stereotype (let's say A
here) in order to create a more refined PrimitiveType
metaclass. If you do this, in your UML model, you will be able to create A
instances, but you will not be abe to use A
as a Property
type. The only objects you will be able to use will be the created A
instances.