@Test public void testCreate() { BAG bag = new AfpBuilder().create(BAG.class); assertNotNull(bag); }
@SuppressWarnings("unchecked") public <T extends EObject> T create(Class<T> clazz) { EClass eclass; EClassifier classifier = AfplibPackage.eINSTANCE.getEClassifier(clazz.getSimpleName()); if(classifier == null) throw new IllegalArgumentException(clazz.getName()+" is not a structured field or triplet class."); eclass = (EClass) classifier; EObject eobj = AfplibFactory.eINSTANCE.create(eclass); for(Entry<Integer, Object> e : values.entrySet()) { EStructuralFeature feature = eobj.eClass().getEStructuralFeature(e.getKey()); eobj.eSet(feature, e.getValue()); } for(EObject m : member) { Integer containerClassifierID = null; if(m instanceof SF) { containerClassifierID = BasePackage.SF__CHILDREN; } else { for(EReference ref : eclass.getEAllReferences()) { if(ref.equals(BasePackage.Literals.SF__CHILDREN)) continue; containerClassifierID = ref.getFeatureID(); } } if(containerClassifierID == null) throw new IllegalArgumentException(clazz.getName()+" cannot contain triplets nor repeating groups."); EStructuralFeature feature = eobj.eClass().getEStructuralFeature(containerClassifierID); List<Object> list = (List<Object>) eobj.eGet(feature); list.add(m); } return (T) eobj; }
AfpBuilder { @SuppressWarnings("unchecked") public <T extends EObject> T create(Class<T> clazz) { EClass eclass; EClassifier classifier = AfplibPackage.eINSTANCE.getEClassifier(clazz.getSimpleName()); if(classifier == null) throw new IllegalArgumentException(clazz.getName()+" is not a structured field or triplet class."); eclass = (EClass) classifier; EObject eobj = AfplibFactory.eINSTANCE.create(eclass); for(Entry<Integer, Object> e : values.entrySet()) { EStructuralFeature feature = eobj.eClass().getEStructuralFeature(e.getKey()); eobj.eSet(feature, e.getValue()); } for(EObject m : member) { Integer containerClassifierID = null; if(m instanceof SF) { containerClassifierID = BasePackage.SF__CHILDREN; } else { for(EReference ref : eclass.getEAllReferences()) { if(ref.equals(BasePackage.Literals.SF__CHILDREN)) continue; containerClassifierID = ref.getFeatureID(); } } if(containerClassifierID == null) throw new IllegalArgumentException(clazz.getName()+" cannot contain triplets nor repeating groups."); EStructuralFeature feature = eobj.eClass().getEStructuralFeature(containerClassifierID); List<Object> list = (List<Object>) eobj.eGet(feature); list.add(m); } return (T) eobj; } }
AfpBuilder { @SuppressWarnings("unchecked") public <T extends EObject> T create(Class<T> clazz) { EClass eclass; EClassifier classifier = AfplibPackage.eINSTANCE.getEClassifier(clazz.getSimpleName()); if(classifier == null) throw new IllegalArgumentException(clazz.getName()+" is not a structured field or triplet class."); eclass = (EClass) classifier; EObject eobj = AfplibFactory.eINSTANCE.create(eclass); for(Entry<Integer, Object> e : values.entrySet()) { EStructuralFeature feature = eobj.eClass().getEStructuralFeature(e.getKey()); eobj.eSet(feature, e.getValue()); } for(EObject m : member) { Integer containerClassifierID = null; if(m instanceof SF) { containerClassifierID = BasePackage.SF__CHILDREN; } else { for(EReference ref : eclass.getEAllReferences()) { if(ref.equals(BasePackage.Literals.SF__CHILDREN)) continue; containerClassifierID = ref.getFeatureID(); } } if(containerClassifierID == null) throw new IllegalArgumentException(clazz.getName()+" cannot contain triplets nor repeating groups."); EStructuralFeature feature = eobj.eClass().getEStructuralFeature(containerClassifierID); List<Object> list = (List<Object>) eobj.eGet(feature); list.add(m); } return (T) eobj; }  }
AfpBuilder { @SuppressWarnings("unchecked") public <T extends EObject> T create(Class<T> clazz) { EClass eclass; EClassifier classifier = AfplibPackage.eINSTANCE.getEClassifier(clazz.getSimpleName()); if(classifier == null) throw new IllegalArgumentException(clazz.getName()+" is not a structured field or triplet class."); eclass = (EClass) classifier; EObject eobj = AfplibFactory.eINSTANCE.create(eclass); for(Entry<Integer, Object> e : values.entrySet()) { EStructuralFeature feature = eobj.eClass().getEStructuralFeature(e.getKey()); eobj.eSet(feature, e.getValue()); } for(EObject m : member) { Integer containerClassifierID = null; if(m instanceof SF) { containerClassifierID = BasePackage.SF__CHILDREN; } else { for(EReference ref : eclass.getEAllReferences()) { if(ref.equals(BasePackage.Literals.SF__CHILDREN)) continue; containerClassifierID = ref.getFeatureID(); } } if(containerClassifierID == null) throw new IllegalArgumentException(clazz.getName()+" cannot contain triplets nor repeating groups."); EStructuralFeature feature = eobj.eClass().getEStructuralFeature(containerClassifierID); List<Object> list = (List<Object>) eobj.eGet(feature); list.add(m); } return (T) eobj; }  AfpBuilder with(int classifierID, Object value); AfpBuilder withMember(EObject tripletOrRG); @SuppressWarnings("unchecked") T create(Class<T> clazz); }
AfpBuilder { @SuppressWarnings("unchecked") public <T extends EObject> T create(Class<T> clazz) { EClass eclass; EClassifier classifier = AfplibPackage.eINSTANCE.getEClassifier(clazz.getSimpleName()); if(classifier == null) throw new IllegalArgumentException(clazz.getName()+" is not a structured field or triplet class."); eclass = (EClass) classifier; EObject eobj = AfplibFactory.eINSTANCE.create(eclass); for(Entry<Integer, Object> e : values.entrySet()) { EStructuralFeature feature = eobj.eClass().getEStructuralFeature(e.getKey()); eobj.eSet(feature, e.getValue()); } for(EObject m : member) { Integer containerClassifierID = null; if(m instanceof SF) { containerClassifierID = BasePackage.SF__CHILDREN; } else { for(EReference ref : eclass.getEAllReferences()) { if(ref.equals(BasePackage.Literals.SF__CHILDREN)) continue; containerClassifierID = ref.getFeatureID(); } } if(containerClassifierID == null) throw new IllegalArgumentException(clazz.getName()+" cannot contain triplets nor repeating groups."); EStructuralFeature feature = eobj.eClass().getEStructuralFeature(containerClassifierID); List<Object> list = (List<Object>) eobj.eGet(feature); list.add(m); } return (T) eobj; }  AfpBuilder with(int classifierID, Object value); AfpBuilder withMember(EObject tripletOrRG); @SuppressWarnings("unchecked") T create(Class<T> clazz);  }