@Override public EList<EAttribute> getEAttributes() { EList<EAttribute> result = new UniqueEList<EAttribute>(); // First iterate through the field clause for (Attribute attribute : getAttributes()) { result.add(attribute.getAttribute()); } // then add the naming clause if (getNamingAttribute() != null) { result.add(getNamingAttribute()); } return result; }
@Override protected void handleOriginalGenModel() throws DiagnosticException { URI genModelURI = getOriginalGenModel().eResource().getURI(); StringBuilder text = new StringBuilder(); getOriginalGenModel().getForeignModel().stream() .filter(value -> value.endsWith(".ecore") || value.endsWith(".emof")) .forEach(value -> text.append(makeAbsolute(URI.createURI(value), genModelURI).toString()).append(' ')); if (text.length() == 0) { List<URI> locations = new UniqueEList<>(); for (GenPackage genPackage : getOriginalGenModel().getGenPackages()) { URI ecoreURI = genPackage.getEcorePackage().eResource().getURI(); if (locations.add(ecoreURI)) { text.append(makeAbsolute(URI.createURI(ecoreURI.toString()), genModelURI).toString()).append(' '); } } } setModelLocation(text.toString().trim()); }
public EList<EClass> getSubclasses() { if (subclasses == null) { subclasses = new UniqueEList<EClass>() { private static final long serialVersionUID = 1L; @Override protected Object [] newData(int capacity) { return new EClass [capacity]; } @Override protected boolean useEquals() { return false; } }; } return subclasses; }
/** * Returns the default file extension filters. This method should only be used to initialize {@link #FILE_EXTENSION_FILTERS}. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ private static String[] getFileExtensionFilters() { List<String> result = new UniqueEList<String>(); result.addAll(OverviewEditor.FILE_EXTENSION_FILTERS); result.addAll(CoreEditor.FILE_EXTENSION_FILTERS); result.addAll(ApplicationEditor.FILE_EXTENSION_FILTERS); result.addAll(ArchitectureEditor.FILE_EXTENSION_FILTERS); result.addAll(DeploymentEditor.FILE_EXTENSION_FILTERS); result.addAll(SpecificationEditor.FILE_EXTENSION_FILTERS); result.addAll(SlaEditor.FILE_EXTENSION_FILTERS); result.addAll(ParametertypeEditor.FILE_EXTENSION_FILTERS); return result.toArray(new String[0]); }
public EList<EReference> getEAllContainments() { if (eAllContainments == null) { BasicEList<EReference> result = new UniqueEList<EReference>() { private static final long serialVersionUID = 1L; @Override protected Object [] newData(int capacity) { return new EReference [capacity]; } @Override protected boolean useEquals() { return false; } }; for (EReference eReference : getEAllReferences()) { if (eReference.isContainment()) { result.add(eReference); } } result.shrink(); eAllContainments = new EcoreEList.UnmodifiableEList.FastCompare<EReference> (this, EcorePackage.eINSTANCE.getEClass_EAllContainments(), result.size(), result.data()); getESuperAdapter().setAllContainmentsCollectionModified(false); } return eAllContainments; }
@Override public void applyAndReverse() { preApply(true); List<EObject> objectsBeforeApply = new UniqueEList.FastCompare<EObject>(); List<EObject> objectsAfterApply = new UniqueEList.FastCompare<EObject>(); // Apply the change and reverse the change information. // for (Map.Entry<EObject, EList<FeatureChange>> entry : getObjectChanges()) { try { applyAndReverseObjectChanges(entry, objectsBeforeApply, objectsAfterApply); } catch (Exception e) { LogUtil.errorOnce("applying object change: " + e.getMessage()); } } for (ResourceChange resourceChange : getResourceChanges()) { Resource resource = resourceChange.getResource(); if (resource != null) { objectsBeforeApply.addAll(resource.getContents()); } resourceChange.applyAndReverse(); if (resource != null) { objectsAfterApply.addAll(resource.getContents()); } } // The next line leaves objectsBeforeApply with all the objects that // were // added during the last recording. objectsBeforeApply.removeAll(objectsAfterApply); // Reverse the objects to attach and detach lists. // getObjectsToAttach().clear(); for (EObject eObject : objectsBeforeApply) { if (eObject.eContainer() == null && eObject.eResource() == null) { getObjectsToAttach().add(eObject); } } oldContainmentInformation = null; }
/** * Creates a {@link #resourceMap resource map} entry for the resource with the given normalized URI. */ protected void map(URI normalizedURI, Resource resource) { // If there is no entry yet... // EList<Resource> value = resourceMap.get(normalizedURI); if (value == null) { // Create a mapping to a singleton list. // resourceMap.put(normalizedURI, ECollections.singletonEList(resource)); } else { // Otherwise, we need to add to the value list. // Create new list if the list is a singleton, and add the resource to it. // if (value.size() == 1) { value = new UniqueEList.FastCompare<Resource>(value); } value.add(resource); // Ensure that the resources are ordered as they are in the resource set's list of resources. // Note that resources not in the resource set (i.e., those found by calling delegatedGetResource) come last. // int count = 0; for (Resource r : resourceSet.getResources()) { int index = value.indexOf(r); if (index != -1) { value.move(count++, index); } } // Update the map with the new value. // resourceMap.put(normalizedURI, value); } }
/** * Validates the UniqueNsURIs constraint of '<em>EPackage</em>'. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated NOT */ public boolean validateEPackage_UniqueNsURIs(EPackage ePackage, DiagnosticChain diagnostics, Map<Object, Object> context) { boolean result = true; String nsURI = ePackage.getNsURI(); if (nsURI != null) { EPackage rootEPackage = ePackage; for (EPackage eSuperPackage = ePackage.getESuperPackage(); eSuperPackage != null; eSuperPackage = eSuperPackage.getESuperPackage()) { rootEPackage = eSuperPackage; } UniqueEList<EPackage> ePackages = new UniqueEList.FastCompare<EPackage>(); ePackages.add(rootEPackage); for (int i = 0; i < ePackages.size(); ++i) { ePackages.addAll(ePackages.get(i).getESubpackages()); } ePackages.remove(ePackage); for (EPackage otherEPackage : ePackages) { if (nsURI.equals(otherEPackage.getNsURI())) { if (diagnostics == null) { return false; } else { result = false; diagnostics.add (createDiagnostic (Diagnostic.ERROR, DIAGNOSTIC_SOURCE, UNIQUE_NS_URIS, "_UI_EPackageUniqueNsURIs_diagnostic", new Object[] { nsURI }, new Object[] { ePackage, otherEPackage, EcorePackage.Literals.EPACKAGE__ESUBPACKAGES }, context)); } } } } return result; }
public List<EStructuralFeature> getAllAttributes(EClass eClass) { List<EClass> superTypes = eClass.getESuperTypes(); List<EStructuralFeature> result = null; boolean changeable = false; for (int i = 0, size = superTypes.size(); i < size; ++i) { EClass eSuperType = superTypes.get(i); List<EStructuralFeature> allAttributes = getAllAttributes(eSuperType); if (!allAttributes.isEmpty()) { if (result == null) { result = allAttributes; } else { if (!changeable) { changeable = true; result = new UniqueEList<EStructuralFeature>(result); } result.addAll(allAttributes); } } } List<EStructuralFeature> attributes = getAttributes(eClass); if (!attributes.isEmpty()) { if (result == null) { return attributes; } else { if (!changeable) { result = new UniqueEList<EStructuralFeature>(result); } result.addAll(attributes); return result; } } else { return result == null ? Collections.<EStructuralFeature>emptyList() : result; } }
public List<EStructuralFeature> getAllElements(EClass eClass) { List<EClass> superTypes = eClass.getESuperTypes(); List<EStructuralFeature> result = null; boolean changeable = false; for (int i = 0, size = superTypes.size(); i < size; ++i) { EClass eSuperType = superTypes.get(i); List<EStructuralFeature> allElements = getAllElements(eSuperType); if (!allElements.isEmpty()) { if (result == null) { result = allElements; } else { if (!changeable) { changeable = true; result = new UniqueEList<EStructuralFeature>(result); } result.addAll(allElements); } } } List<EStructuralFeature> elements = getElements(eClass); if (!elements.isEmpty()) { if (result == null) { return elements; } else { if (!changeable) { result = new UniqueEList<EStructuralFeature>(result); } result.addAll(elements); return result; } } else { return result == null ? Collections.<EStructuralFeature>emptyList() : result; } }
public EList<EReference> getEAllReferences() { if (eAllReferences == null) { class ReferenceList extends UniqueEList<EReference> { private static final long serialVersionUID = 1L; public ReferenceList() { super(); } @Override protected Object [] newData(int capacity) { return new EReference [capacity]; } @Override protected boolean useEquals() { return false; } } BasicEList<EReference> result = new ReferenceList(); BasicEList<EReference> references = new ReferenceList(); Set<EClass> computationInProgress = COMPUTATION_IN_PROGRESS.get(); if (computationInProgress.add(this)) { for (EClass eSuperType : getESuperTypes()) { result.addAll(eSuperType.getEAllReferences()); } computationInProgress.remove(this); if (computationInProgress.isEmpty()) { COMPUTATION_IN_PROGRESS.remove(); } } for (EStructuralFeature eStructuralFeature : getEStructuralFeatures()) { if (eStructuralFeature instanceof EReference) { references.add((EReference)eStructuralFeature); } } references.shrink(); eReferences = new EcoreEList.UnmodifiableEList.FastCompare<EReference> (this, EcorePackage.eINSTANCE.getEClass_EReferences(), references.size(), references.data()) { private static final long serialVersionUID = 1L; @SuppressWarnings("unchecked") @Override public void addUnique(EReference object) { ((InternalEList<EReference>)(InternalEList<?>)getEStructuralFeatures()).addUnique(object); } @Override public boolean add(EReference object) { System.err.println("Please fix your code to add using EClass.getEStructuralFeatures() instead of EClass.getEReferences()"); return getEStructuralFeatures().add(object); } }; result.addAll(eReferences); result.shrink(); eAllReferences = new EcoreEList.UnmodifiableEList.FastCompare<EReference> (this, EcorePackage.eINSTANCE.getEClass_EAllReferences(), result.size(), result.data()); getESuperAdapter().setAllReferencesCollectionModified(false); } return eAllReferences; }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated modifiable */ public EList<EOperation> getEAllOperations() { if (eAllOperations == null) { BasicEList<EOperation> result = new UniqueEList<EOperation>() { private static final long serialVersionUID = 1L; @Override protected Object [] newData(int capacity) { return new EOperation [capacity]; } @Override protected boolean useEquals() { return false; } }; Set<EClass> computationInProgress = COMPUTATION_IN_PROGRESS.get(); if (computationInProgress.add(this)) { for (EClass eSuperType : getESuperTypes()) { result.addAll(eSuperType.getEAllOperations()); } computationInProgress.remove(this); if (computationInProgress.isEmpty()) { COMPUTATION_IN_PROGRESS.remove(); } } int operationID = result.size(); for (Iterator<EOperation> i = getEOperations().iterator(); i.hasNext(); ++operationID) { ((EOperationImpl)i.next()).setOperationID(operationID); } result.addAll(getEOperations()); result.shrink(); eAllOperations = new EcoreEList.UnmodifiableEList.FastCompare<EOperation> (this, EcorePackage.eINSTANCE.getEClass_EAllOperations(), result.size(), result.data()); eAllOperationsData = (EOperation[])result.data(); if (eAllOperationsData == null) { eAllOperationsData = NO_EALL_OPERATIONS_DATA; } eOperationToOverrideMap = null; getESuperAdapter().setAllOperationsCollectionModified(false); } return eAllOperations; }
/** * Returns all the super types in the hierarchy. */ public EList<EClass> getEAllSuperTypes() { if (eAllSuperTypes == null) { BasicEList<EClass> result = new UniqueEList<EClass>() { private static final long serialVersionUID = 1L; @Override protected Object [] newData(int capacity) { return new EClassifier [capacity]; } @Override protected boolean useEquals() { return false; } }; Set<EClass> computationInProgress = COMPUTATION_IN_PROGRESS.get(); if (computationInProgress.add(this)) { for (EClass eSuperType : getESuperTypes()) { EList<EClass> higherSupers = eSuperType.getEAllSuperTypes(); result.addAll(higherSupers); result.add(eSuperType); } computationInProgress.remove(this); } result.shrink(); eAllSuperTypes = new EcoreEList.UnmodifiableEList.FastCompare<EClass> (this, EcorePackage.eINSTANCE.getEClass_EAllSuperTypes(), result.size(), result.data()); getESuperAdapter().setAllSuperCollectionModified(false); } return eAllSuperTypes; }
/** * Validates the UniqueNsURIs constraint of '<em>EPackage</em>'. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated NOT */ public boolean validateEPackage_UniqueNsURIs(EPackage ePackage, DiagnosticChain diagnostics, Map<Object, Object> context) { boolean result = true; String nsURI = ePackage.getNsURI(); if (nsURI != null) { EPackage rootEPackage = ePackage; for (EPackage eSuperPackage = ePackage.getESuperPackage(); eSuperPackage != null; eSuperPackage = eSuperPackage.getESuperPackage()) { rootEPackage = eSuperPackage; } UniqueEList<EPackage> ePackages = new UniqueEList.FastCompare<EPackage>(); ePackages.add(rootEPackage); for (int i = 0; i < ePackages.size(); ++i) { ePackages.addAll(ePackages.get(i).getESubpackages()); } ePackages.remove(ePackage); for (EPackage otherEPackage : ePackages) { if (nsURI.equals(otherEPackage.getNsURI())) { if (diagnostics == null) { return false; } else { result = false; diagnostics.add (createDiagnostic (Diagnostic.ERROR, DIAGNOSTIC_SOURCE, UNIQUE_NS_URIS, "_UI_EPackageUniqueNsURIs_diagnostic", new Object[] { nsURI }, new Object[] { ePackage, otherEPackage }, context)); } } } } return result; }
public EList<EReference> getEAllReferences() { if (eAllReferences == null) { class ReferenceList extends UniqueEList<EReference> { private static final long serialVersionUID = 1L; public ReferenceList() { super(); } @Override protected Object [] newData(int capacity) { return new EReference [capacity]; } @Override protected boolean useEquals() { return false; } } BasicEList<EReference> result = new ReferenceList(); BasicEList<EReference> references = new ReferenceList(); Set<EClass> computationInProgress = COMPUTATION_IN_PROGRESS.get(); if (computationInProgress.add(this)) { for (EClass eSuperType : getESuperTypes()) { result.addAll(eSuperType.getEAllReferences()); } computationInProgress.remove(this); } for (EStructuralFeature eStructuralFeature : getEStructuralFeatures()) { if (eStructuralFeature instanceof EReference) { references.add((EReference)eStructuralFeature); } } references.shrink(); eReferences = new EcoreEList.UnmodifiableEList.FastCompare<EReference> (this, EcorePackage.eINSTANCE.getEClass_EReferences(), references.size(), references.data()) { private static final long serialVersionUID = 1L; @SuppressWarnings("unchecked") @Override public void addUnique(EReference object) { ((InternalEList<EReference>)(InternalEList<?>)getEStructuralFeatures()).addUnique(object); } @Override public boolean add(EReference object) { System.err.println("Please fix your code to add using EClass.getEStructuralFeatures() instead of EClass.getEReferences()"); return getEStructuralFeatures().add(object); } }; result.addAll(eReferences); result.shrink(); eAllReferences = new EcoreEList.UnmodifiableEList.FastCompare<EReference> (this, EcorePackage.eINSTANCE.getEClass_EAllReferences(), result.size(), result.data()); getESuperAdapter().setAllReferencesCollectionModified(false); } return eAllReferences; }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated modifiable */ public EList<EOperation> getEAllOperations() { if (eAllOperations == null) { BasicEList<EOperation> result = new UniqueEList<EOperation>() { private static final long serialVersionUID = 1L; @Override protected Object [] newData(int capacity) { return new EOperation [capacity]; } @Override protected boolean useEquals() { return false; } }; Set<EClass> computationInProgress = COMPUTATION_IN_PROGRESS.get(); if (computationInProgress.add(this)) { for (EClass eSuperType : getESuperTypes()) { result.addAll(eSuperType.getEAllOperations()); } computationInProgress.remove(this); } int operationID = result.size(); for (Iterator<EOperation> i = getEOperations().iterator(); i.hasNext(); ++operationID) { ((EOperationImpl)i.next()).setOperationID(operationID); } result.addAll(getEOperations()); result.shrink(); eAllOperations = new EcoreEList.UnmodifiableEList.FastCompare<EOperation> (this, EcorePackage.eINSTANCE.getEClass_EAllOperations(), result.size(), result.data()); eAllOperationsData = (EOperation[])result.data(); if (eAllOperationsData == null) { eAllOperationsData = NO_EALL_OPERATIONS_DATA; } eOperationToOverrideMap = null; getESuperAdapter().setAllOperationsCollectionModified(false); } return eAllOperations; }
/** * Returns the default file extension filters. This method should only be used to initialize {@link #FILE_EXTENSION_FILTERS}. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ private static String[] getFileExtensionFilters() { List<String> result = new UniqueEList<String>(); result.addAll(DictionaryEditor.FILE_EXTENSION_FILTERS); return result.toArray(new String[0]); }