public Property createOwnedReference(Class aClass, String name, Class type) { return aClass.createOwnedAttribute(name, type); }
@Override protected void setUp() { super.setUp(); pkg = umlf.createPackage(); pkg.setName("pkg"); valueType = pkg.createOwnedPrimitiveType("Value"); valueType .createOwnedOperation( "<", new BasicEList<String>(Collections.singleton("v")), new BasicEList<Type>(Collections.singleton(valueType)), getUMLBoolean()) .setIsQuery(true); valueType .createOwnedOperation( "<=", new BasicEList<String>(Collections.singleton("v")), new BasicEList<Type>(Collections.singleton(valueType)), getUMLBoolean()) .setIsQuery(true); valueType .createOwnedOperation( ">", new BasicEList<String>(Collections.singleton("v")), new BasicEList<Type>(Collections.singleton(valueType)), getUMLBoolean()) .setIsQuery(true); valueType .createOwnedOperation( ">=", new BasicEList<String>(Collections.singleton("v")), new BasicEList<Type>(Collections.singleton(valueType)), getUMLBoolean()) .setIsQuery(true); thingType = pkg.createOwnedClass("Thing", false); values = thingType.createOwnedAttribute("values", valueType); values.setUpper(LiteralUnlimitedNatural.UNLIMITED); values.setIsOrdered(true); values.setIsUnique(true); bdValue = thingType.createOwnedAttribute("bdValue", getEcoreBigDecimal()); biValue = thingType.createOwnedAttribute("biValue", getEcoreBigInteger()); numeroType = pkg.createOwnedClass("Numero", false); numeroType .createOwnedOperation( "+", new BasicEList<String>(Collections.singleton("n")), new BasicEList<Type>(Collections.singleton(numeroType)), numeroType) .setIsQuery(true); numeroType .createOwnedOperation( "-", new BasicEList<String>(Collections.singleton("n")), new BasicEList<Type>(Collections.singleton(numeroType)), numeroType) .setIsQuery(true); numeroType .createOwnedOperation( "*", new BasicEList<String>(Collections.singleton("n")), new BasicEList<Type>(Collections.singleton(numeroType)), numeroType) .setIsQuery(true); numeroType .createOwnedOperation( "/", new BasicEList<String>(Collections.singleton("n")), new BasicEList<Type>(Collections.singleton(numeroType)), numeroType) .setIsQuery(true); numeroType .createOwnedOperation( "-", ECollections.<String>emptyEList(), ECollections.<Type>emptyEList(), numeroType) .setIsQuery(true); numeroType .createOwnedOperation( "<", new BasicEList<String>(Collections.singleton("n")), new BasicEList<Type>(Collections.singleton(numeroType)), getUMLBoolean()) .setIsQuery(true); numeroType .createOwnedOperation( "<=", new BasicEList<String>(Collections.singleton("n")), new BasicEList<Type>(Collections.singleton(numeroType)), getUMLBoolean()) .setIsQuery(true); numeroType .createOwnedOperation( ">", new BasicEList<String>(Collections.singleton("n")), new BasicEList<Type>(Collections.singleton(numeroType)), getUMLBoolean()) .setIsQuery(true); numeroType .createOwnedOperation( ">=", new BasicEList<String>(Collections.singleton("n")), new BasicEList<Type>(Collections.singleton(numeroType)), getUMLBoolean()) .setIsQuery(true); numeroType .createOwnedOperation( "asLong", ECollections.<String>emptyEList(), ECollections.<Type>emptyEList(), getEcoreLong()) .setIsQuery(true); numeros = thingType.createOwnedAttribute("numeros", numeroType); numeros.setUpper(LiteralUnlimitedNatural.UNLIMITED); numeros.setIsOrdered(true); numeros.setIsUnique(true); comparable = pkg.createOwnedClass("Comparable", true); comparable .createOwnedOperation( "compareTo", new BasicEList<String>(Collections.singleton("c")), new BasicEList<Type>(Collections.singleton(comparable)), getUMLInteger()) .setIsQuery(true); // the Ecore counterpart epkg = UMLUtil.convertToEcore(pkg, null).iterator().next(); ethingType = (EClass) epkg.getEClassifier(thingType.getName()); enumeros = (EReference) ethingType.getEStructuralFeature(numeros.getName()); evalues = (EAttribute) ethingType.getEStructuralFeature(values.getName()); ebdValue = (EAttribute) ethingType.getEStructuralFeature(bdValue.getName()); ebiValue = (EAttribute) ethingType.getEStructuralFeature(biValue.getName()); enumeroType = (EClass) epkg.getEClassifier(numeroType.getName()); enumeroType.setInstanceClass(Numero.class); evalueType = (EDataType) epkg.getEClassifier(valueType.getName()); evalueType.setInstanceClass(Value.class); efactory = epkg.getEFactoryInstance(); thing = efactory.create(ethingType); EPackage.Registry.INSTANCE.put(epkg.getNsURI(), epkg); @SuppressWarnings("unchecked") EList<Numero> list = (EList<Numero>) thing.eGet(enumeros); list.add(new Numero(6)); list.add(new Numero(2)); }