public void addIndex(EStructuralFeature eStructuralFeature) { for (EAnnotation eAnnotation : eStructuralFeature.getEAnnotations()) { if (eAnnotation.getSource().equals("singleindex")) { throw new RuntimeException(eStructuralFeature + " already has an index"); } } changes.add(new AddIndexChange(this, eStructuralFeature)); EAnnotation index = EcoreFactory.eINSTANCE.createEAnnotation(); index.setSource("singleindex"); eStructuralFeature.getEAnnotations().add(index); }
@Override protected void copyContainment(EReference eReference, EObject eObject, EObject copyEObject) { // The eAnnotations and eGenericType are possible containment references. // We'll move them instead of copying // if (eReference == EcorePackage.Literals.ETYPED_ELEMENT__EGENERIC_TYPE) { ((ETypedElement)copyEObject).setEGenericType(((ETypedElement)eObject).getEGenericType()); } else { ((EStructuralFeature)copyEObject).getEAnnotations().addAll(((EStructuralFeature)eObject).getEAnnotations()); } } @Override
@Override protected void copyContainment(EReference eReference, EObject eObject, EObject copyEObject) { // The eAnnotations and eGenericType are possible containment references. // We'll move them instead of copying // if (eReference == EcorePackage.Literals.ETYPED_ELEMENT__EGENERIC_TYPE) { ((ETypedElement)copyEObject).setEGenericType(((ETypedElement)eObject).getEGenericType()); } else { ((EStructuralFeature)copyEObject).getEAnnotations().addAll(((EStructuralFeature)eObject).getEAnnotations()); } } @Override
/** * Sets or removes annotations on the given structural feature to prevent generation of accessor methods in its interface. * @param eStructuralFeature the structural feature * @param accessor the type of accessor method, one of {@link #GET}, {@link #SET}, {@link #IS_SET}, or {@link #UNSET} * @param suppress whether the specified accessor's visibility should be suppressed * @since 2.1 */ public static void setSuppressedVisibility(EStructuralFeature eStructuralFeature, int accessor, boolean suppress) { if (accessor < GET || accessor > UNSET) throw new IllegalArgumentException("Invalid accessor identifier: " + accessor); EAnnotation eAnnotation = eStructuralFeature.getEAnnotation(GEN_MODEL_PACKAGE_NS_URI); if (!suppress) { if (eAnnotation != null) { eAnnotation.getDetails().removeKey(ACCESSOR_KEYS[accessor]); } } else { if (eAnnotation == null) { eAnnotation = EcoreFactory.eINSTANCE.createEAnnotation(); eAnnotation.setSource(GEN_MODEL_PACKAGE_NS_URI); eStructuralFeature.getEAnnotations().add(eAnnotation); } eAnnotation.getDetails().put(ACCESSOR_KEYS[accessor], TRUE); } }
/** * Sets or removes annotations on the given structural feature to prevent generation of accessor methods in its interface. * @param eStructuralFeature the structural feature * @param accessor the type of accessor method, one of {@link #GET}, {@link #SET}, {@link #IS_SET}, or {@link #UNSET} * @param suppress whether the specified accessor's visibility should be suppressed * @since 2.1 */ public static void setSuppressedVisibility(EStructuralFeature eStructuralFeature, int accessor, boolean suppress) { if (accessor < GET || accessor > UNSET) throw new IllegalArgumentException("Invalid accessor identifier: " + accessor); EAnnotation eAnnotation = eStructuralFeature.getEAnnotation(GEN_MODEL_PACKAGE_NS_URI); if (!suppress) { if (eAnnotation != null) { eAnnotation.getDetails().removeKey(ACCESSOR_KEYS[accessor]); } } else { if (eAnnotation == null) { eAnnotation = EcoreFactory.eINSTANCE.createEAnnotation(); eAnnotation.setSource(GEN_MODEL_PACKAGE_NS_URI); eStructuralFeature.getEAnnotations().add(eAnnotation); } eAnnotation.getDetails().put(ACCESSOR_KEYS[accessor], TRUE); } }
ann = EcoreFactory.eINSTANCE.createEAnnotation(); ann.setSource(Environment.OCL_NAMESPACE_URI); result.getEAnnotations().add(ann);