Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEd Willink2016-10-28 17:16:09 +0000
committerEd Willink2016-10-29 17:36:28 +0000
commit0df4b4de9c9f52098c2a5004004bf5f7f3642908 (patch)
treeb8d816eae0265337bd4b198603da0f7b1b585d21
parent5de3b6fa8b55999c43a879e1a3b365b4a5e5a69f (diff)
downloadorg.eclipse.qvtd-0df4b4de9c9f52098c2a5004004bf5f7f3642908.tar.gz
org.eclipse.qvtd-0df4b4de9c9f52098c2a5004004bf5f7f3642908.tar.xz
org.eclipse.qvtd-0df4b4de9c9f52098c2a5004004bf5f7f3642908.zip
[506716] Use @NonNull throughout ClassRelationships
-rw-r--r--plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvtp2qvts/ClassRelationships.java238
1 files changed, 118 insertions, 120 deletions
diff --git a/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvtp2qvts/ClassRelationships.java b/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvtp2qvts/ClassRelationships.java
index fa7ed4fbe..4d47f77aa 100644
--- a/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvtp2qvts/ClassRelationships.java
+++ b/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvtp2qvts/ClassRelationships.java
@@ -25,10 +25,8 @@ import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.ocl.pivot.Class;
import org.eclipse.ocl.pivot.CollectionType;
import org.eclipse.ocl.pivot.Model;
-import org.eclipse.ocl.pivot.Package;
import org.eclipse.ocl.pivot.Property;
import org.eclipse.ocl.pivot.Type;
import org.eclipse.ocl.pivot.TypedElement;
@@ -44,157 +42,157 @@ import org.eclipse.ocl.pivot.utilities.MetamodelManager;
* @param <C>
*/
public class ClassRelationships {
- private static final @NonNull Set<@NonNull Class> EMPTY_CLASS_SET = Collections.<@NonNull Class>emptySet();
+ private static final @NonNull Set<org.eclipse.ocl.pivot.@NonNull Class> EMPTY_CLASS_SET = Collections.emptySet();
public static class ContainerClass {
-
- private @NonNull Class containerClass;
-
+
+ private org.eclipse.ocl.pivot.@NonNull Class containerClass;
+
private @NonNull Property containmentProperty;
-
- public ContainerClass(@NonNull Class containerClass, @NonNull Property containmentProperty) {
+
+ public ContainerClass(org.eclipse.ocl.pivot.@NonNull Class containerClass, @NonNull Property containmentProperty) {
this.containerClass = containerClass;
this.containmentProperty = containmentProperty;
}
-
- public @NonNull Class getContainerClass() {
+
+ public org.eclipse.ocl.pivot.@NonNull Class getContainerClass() {
return containerClass;
}
-
+
public @NonNull Property getContainmentProperty() {
return containmentProperty;
}
-
+
@Override
public @NonNull String toString() {
-
+
return containerClass.getName() + " - " + containmentProperty.getName();
}
}
-
- private @NonNull Map<@NonNull Class, Set<@NonNull Class>> class2superClasses = new HashMap<@NonNull Class, Set<@NonNull Class>>();
-
- private @NonNull Map<@NonNull Class, Set<@NonNull Class>> class2directSubClasses = new HashMap<@NonNull Class, Set<@NonNull Class>>();
-
- private @NonNull Map<@NonNull Class, Set<@NonNull Class>> class2allSubClasses = new HashMap<@NonNull Class, Set<@NonNull Class>>();
-
- private @NonNull Map<@NonNull Class, Set<@NonNull Class>> class2containerClasses = new HashMap<@NonNull Class, Set<@NonNull Class>>();
-
- private @NonNull Map<@NonNull Class, Set<@NonNull ContainerClass>> class2detailedContainerClasses = new HashMap<@NonNull Class, Set<@NonNull ContainerClass>>();
-
+
+ private @NonNull Map<org.eclipse.ocl.pivot.@NonNull Class, @NonNull Set<org.eclipse.ocl.pivot.@NonNull Class>> class2superClasses = new HashMap<>();
+
+ private @NonNull Map<org.eclipse.ocl.pivot.@NonNull Class, @NonNull Set<org.eclipse.ocl.pivot.@NonNull Class>> class2directSubClasses = new HashMap<>();
+
+ private @NonNull Map<org.eclipse.ocl.pivot.@NonNull Class, @NonNull Set<org.eclipse.ocl.pivot.@NonNull Class>> class2allSubClasses = new HashMap<>();
+
+ private @NonNull Map<org.eclipse.ocl.pivot.@NonNull Class, @NonNull Set<org.eclipse.ocl.pivot.@NonNull Class>> class2containerClasses = new HashMap<>();
+
+ private @NonNull Map<org.eclipse.ocl.pivot.@NonNull Class, @NonNull Set<@NonNull ContainerClass>> class2detailedContainerClasses = new HashMap<>();
+
protected @NonNull MetamodelManager mManager;
-
- private Deque<@NonNull Package> packageToProcess = new LinkedList<@NonNull Package>();
-
- private Set<@NonNull Package> processedPackage = new HashSet<@NonNull Package>();
-
+
+ private @NonNull Deque<org.eclipse.ocl.pivot.@NonNull Package> packageToProcess = new LinkedList<>();
+
+ private @NonNull Set<org.eclipse.ocl.pivot.@NonNull Package> processedPackage = new HashSet<>();
+
public ClassRelationships(@NonNull EnvironmentFactory ocl) {
mManager = ocl.getMetamodelManager();
((MetamodelManagerInternal)mManager).getASmetamodel();
initializeMaps(ocl.getMetamodelManager().getASResourceSet());
}
-
+
private void initializeMaps(@NonNull ResourceSet resourceSet) {
-
- for (Resource resource : resourceSet.getResources()) {
- for (@SuppressWarnings("null") @NonNull Package aPackage : getInvolvedPackages(resource)) {
- Package pPackage = mManager.getPrimaryPackage(aPackage);
+
+ for (@NonNull Resource resource : ClassUtil.nullFree(resourceSet.getResources())) {
+ for (org.eclipse.ocl.pivot.@NonNull Package aPackage : getInvolvedPackages(resource)) {
+ org.eclipse.ocl.pivot.Package pPackage = mManager.getPrimaryPackage(aPackage);
if (!packageToProcess.contains(pPackage)) {
packageToProcess.add(pPackage);;
}
}
}
-
+
while (!packageToProcess.isEmpty()) {
- Package aPackage = packageToProcess.pop();
+ org.eclipse.ocl.pivot.Package aPackage = packageToProcess.pop();
computeClass2SuperClasses(aPackage);
}
-
- for (Class type : class2superClasses.keySet()) {
+
+ for (org.eclipse.ocl.pivot.Class type : class2superClasses.keySet()) {
computeClass2SubClasses(type);
}
- for (Class type : class2superClasses.keySet()) { // subtypes need to be previously computed
+ for (org.eclipse.ocl.pivot.Class type : class2superClasses.keySet()) { // subtypes need to be previously computed
computeClass2ContainerClasses(type);
}
}
-
-
- private void computeClass2SuperClasses(@NonNull Package p) {
-
+
+
+ private void computeClass2SuperClasses(org.eclipse.ocl.pivot.@NonNull Package p) {
+
if (processedPackage.contains(p)) {
return;
- }
+ }
processedPackage.add(p);
- for (Class aClass : ClassUtil.nullFree(p.getOwnedClasses())) {
+ for (org.eclipse.ocl.pivot.Class aClass : ClassUtil.nullFree(p.getOwnedClasses())) {
computeClass2SuperClasses(aClass);
}
- for (Package nestedPackage : ClassUtil.nullFree(p.getOwnedPackages())) {
+ for (org.eclipse.ocl.pivot.Package nestedPackage : ClassUtil.nullFree(p.getOwnedPackages())) {
computeClass2SuperClasses(nestedPackage);
}
}
-
+
/**
* Tranisitively compute
* @param aClass
* @return a set with all the all classess
*/
- private @NonNull Set<@NonNull Class> computeClass2SuperClasses(@NonNull Class aClass) {
-
+ private @NonNull Set<org.eclipse.ocl.pivot.@NonNull Class> computeClass2SuperClasses(org.eclipse.ocl.pivot.@NonNull Class aClass) {
+
//aClass = mManager.getPrimaryClass(aClass);
- Set<@NonNull Class> superRels = class2superClasses.get(aClass);
+ Set<org.eclipse.ocl.pivot.@NonNull Class> superRels = class2superClasses.get(aClass);
if (superRels != null) {
return superRels;
} else {
- superRels = new LinkedHashSet<@NonNull Class>();
+ superRels = new LinkedHashSet<>();
class2superClasses.put(aClass, superRels);
}
-
- // Super class inheritance might be shortcut
- for (@NonNull Class superClass : ClassUtil.nullFree(aClass.getSuperClasses())) {
+
+ // Super class inheritance might be shortcut
+ for (org.eclipse.ocl.pivot.@NonNull Class superClass : ClassUtil.nullFree(aClass.getSuperClasses())) {
//superClass = mManager.getPrimaryClass(superClass);
superRels.add(superClass);
superRels.addAll(computeClass2SuperClasses(superClass));
}
-
- Package classPackage = ClassUtil.nonNullState(aClass.getOwningPackage());
- Package pPackage = mManager.getPrimaryPackage(classPackage);
+
+ org.eclipse.ocl.pivot.Package classPackage = ClassUtil.nonNullState(aClass.getOwningPackage());
+ org.eclipse.ocl.pivot.Package pPackage = mManager.getPrimaryPackage(classPackage);
if (!processedPackage.contains(pPackage) &&
- ! packageToProcess.contains(pPackage)) {
+ ! packageToProcess.contains(pPackage)) {
packageToProcess.add(pPackage);
}
return superRels;
}
-
- private void computeClass2SubClasses(Class aClass) {
- Set<@NonNull Class> superClasses = class2superClasses.get(aClass);
+
+ private void computeClass2SubClasses(org.eclipse.ocl.pivot.Class aClass) {
+ Set<org.eclipse.ocl.pivot.@NonNull Class> superClasses = class2superClasses.get(aClass);
if (superClasses != null) {
- for (Class superClass : superClasses) {
+ for (org.eclipse.ocl.pivot.Class superClass : superClasses) {
if (aClass.getSuperClasses().contains(superClass)) {
- Set<Class> directSubClasses = class2directSubClasses.get(superClass);
+ Set<org.eclipse.ocl.pivot.Class> directSubClasses = class2directSubClasses.get(superClass);
if (directSubClasses == null) {
- directSubClasses = new LinkedHashSet<Class>();
+ directSubClasses = new LinkedHashSet<>();
class2directSubClasses.put(superClass, directSubClasses);
}
directSubClasses.add(aClass);
}
-
- Set<Class> allSubClasses = class2allSubClasses.get(superClass);
+
+ Set<org.eclipse.ocl.pivot.Class> allSubClasses = class2allSubClasses.get(superClass);
if (allSubClasses == null) {
- allSubClasses = new LinkedHashSet<Class>();
+ allSubClasses = new LinkedHashSet<>();
class2allSubClasses.put(superClass, allSubClasses);
}
allSubClasses.add(aClass);
}
}
}
-
- private void computeClass2ContainerClasses(@NonNull Class aClass) {
-
- for (Property property : aClass.getOwnedProperties()) {
+
+ private void computeClass2ContainerClasses(org.eclipse.ocl.pivot.@NonNull Class aClass) {
+
+ for (@NonNull Property property : ClassUtil.nullFree(aClass.getOwnedProperties())) {
Type propType = getType(property);
- if (property.isIsComposite() && propType instanceof Class) {
- Class isClass = propType.isClass();
+ if (property.isIsComposite() && propType instanceof org.eclipse.ocl.pivot.Class) {
+ org.eclipse.ocl.pivot.Class isClass = propType.isClass();
assert isClass != null;
addContainerClassForTypeAndSubtypes(aClass, property, isClass);
}
@@ -204,93 +202,93 @@ public class ClassRelationships {
public @NonNull EnvironmentFactory getEnvironmentFactory() {
return mManager.getEnvironmentFactory();
}
-
- private List<Package> getInvolvedPackages(Resource resource) {
-
- List<Model> oclRoots = new ArrayList<Model>();
+
+ private @NonNull List<org.eclipse.ocl.pivot.@NonNull Package> getInvolvedPackages(@NonNull Resource resource) {
+
+ List<@NonNull Model> oclRoots = new ArrayList<>();
for (EObject root : resource.getContents()) {
if (root instanceof Model) {
oclRoots.add((Model)root);
}
}
-
- List<Package> result = new ArrayList<Package>();
+
+ List<org.eclipse.ocl.pivot.@NonNull Package> result = new ArrayList<>();
for (Model root : oclRoots) {
- for (Package pckg : root.getOwnedPackages()) {
+ for (org.eclipse.ocl.pivot.@NonNull Package pckg : ClassUtil.nullFree(root.getOwnedPackages())) {
result.add(pckg);
}
}
return result;
}
-
- protected Type getType(TypedElement typedElement) {
+
+ protected @NonNull Type getType(@NonNull TypedElement typedElement) {
Type type = typedElement.getType();
if (type instanceof CollectionType) {
type = ((CollectionType) type).getElementType();
}
- return type;
+ return ClassUtil.nonNullState(type);
}
- private void addContainerClassForTypeAndSubtypes(@NonNull Class containerClass, @NonNull Property containmentProperty, @NonNull Class type) {
-
+ private void addContainerClassForTypeAndSubtypes(org.eclipse.ocl.pivot.@NonNull Class containerClass, @NonNull Property containmentProperty, org.eclipse.ocl.pivot.@NonNull Class type) {
+
//type = mManager.getPrimaryClass(type);
Set<@NonNull ContainerClass> detailedContainerClasses = class2detailedContainerClasses.get(type);
- Set<@NonNull Class> containerClasses = class2containerClasses.get(type);
+ Set<org.eclipse.ocl.pivot.@NonNull Class> containerClasses = class2containerClasses.get(type);
if (detailedContainerClasses == null) {
- detailedContainerClasses = new LinkedHashSet<@NonNull ContainerClass>();
+ detailedContainerClasses = new LinkedHashSet<>();
class2detailedContainerClasses.put(type, detailedContainerClasses);
}
if (containerClasses == null) {
- containerClasses = new LinkedHashSet<@NonNull Class>();
+ containerClasses = new LinkedHashSet<>();
class2containerClasses.put(type, containerClasses);
}
-
+
detailedContainerClasses.add(new ContainerClass(containerClass, containmentProperty));
containerClasses.add(containerClass);
-
- for (Class subType : getDirectSubClasses(type)) {
+
+ for (org.eclipse.ocl.pivot.Class subType : getDirectSubClasses(type)) {
addContainerClassForTypeAndSubtypes(containerClass, containmentProperty, subType);
- }
+ }
}
-// public boolean typeIsSupertypeOf(Class t1, Class t2) {
-// Type primaryT1 = mManager.getPrimaryClass(t1);
-// Type primaryT2 = mManager.getPrimaryClass(t2);
-// return class2superClasses.get(primaryT1).contains(primaryT2);
-// }
-
-
- public @NonNull Set<@NonNull Class> getAllSuperClasses(@NonNull Class type) {
+ // public boolean typeIsSupertypeOf(Class t1, Class t2) {
+ // Type primaryT1 = mManager.getPrimaryClass(t1);
+ // Type primaryT2 = mManager.getPrimaryClass(t2);
+ // return class2superClasses.get(primaryT1).contains(primaryT2);
+ // }
+
+
+ public @NonNull Set<org.eclipse.ocl.pivot.@NonNull Class> getAllSuperClasses(org.eclipse.ocl.pivot.@NonNull Class type) {
Type primaryType = mManager.getPrimaryClass(type);
- Set<@NonNull Class> allSuperClasses = class2superClasses.get(primaryType);
- return allSuperClasses == null ? EMPTY_CLASS_SET
- : ClassUtil.nonNullState(Collections.<@NonNull Class>unmodifiableSet(allSuperClasses));
+ Set<org.eclipse.ocl.pivot.@NonNull Class> allSuperClasses = class2superClasses.get(primaryType);
+ return allSuperClasses == null ? EMPTY_CLASS_SET
+ : ClassUtil.nonNullState(Collections.<org.eclipse.ocl.pivot.@NonNull Class>unmodifiableSet(allSuperClasses));
}
-
- public @NonNull Set<@NonNull Class> getAllSubClasses(@NonNull Class type) {
+
+ public @NonNull Set<org.eclipse.ocl.pivot.@NonNull Class> getAllSubClasses(org.eclipse.ocl.pivot.@NonNull Class type) {
Type primaryType = mManager.getPrimaryClass(type);
- Set<@NonNull Class> allSubClasses = class2allSubClasses.get(primaryType);
- return allSubClasses == null ? EMPTY_CLASS_SET
- : ClassUtil.nonNullState(Collections.<@NonNull Class>unmodifiableSet(allSubClasses));
+ Set<org.eclipse.ocl.pivot.@NonNull Class> allSubClasses = class2allSubClasses.get(primaryType);
+ return allSubClasses == null ? EMPTY_CLASS_SET
+ : ClassUtil.nonNullState(Collections.<org.eclipse.ocl.pivot.@NonNull Class>unmodifiableSet(allSubClasses));
}
-
- public @NonNull Set<@NonNull Class> getDirectSubClasses(@NonNull Class type) {
+
+ public @NonNull Set<org.eclipse.ocl.pivot.@NonNull Class> getDirectSubClasses(org.eclipse.ocl.pivot.@NonNull Class type) {
Type primaryType = mManager.getPrimaryClass(type);
- Set<@NonNull Class> directSubClasses = class2directSubClasses.get(primaryType);
- return directSubClasses == null ? EMPTY_CLASS_SET
- : ClassUtil.nonNullState(Collections.<@NonNull Class>unmodifiableSet(directSubClasses));
+ Set<org.eclipse.ocl.pivot.@NonNull Class> directSubClasses = class2directSubClasses.get(primaryType);
+ return directSubClasses == null ? EMPTY_CLASS_SET
+ : ClassUtil.nonNullState(Collections.<org.eclipse.ocl.pivot.@NonNull Class>unmodifiableSet(directSubClasses));
}
-
- public @NonNull Set<@NonNull Class> getContainerClasses(@NonNull Class type) {
+
+ public @NonNull Set<org.eclipse.ocl.pivot.@NonNull Class> getContainerClasses(org.eclipse.ocl.pivot.@NonNull Class type) {
Type primaryType = mManager.getPrimaryClass(type);
- Set<@NonNull Class> containerClasses = class2containerClasses.get(primaryType);
+ Set<org.eclipse.ocl.pivot.@NonNull Class> containerClasses = class2containerClasses.get(primaryType);
return containerClasses == null ? EMPTY_CLASS_SET
- : ClassUtil.nonNullState(Collections.<@NonNull Class>unmodifiableSet(containerClasses));
+ : ClassUtil.nonNullState(Collections.<org.eclipse.ocl.pivot.@NonNull Class>unmodifiableSet(containerClasses));
}
-
- public @NonNull Set<@NonNull ContainerClass> getDetailedContainerClasses(@NonNull Class type) {
+
+ public @NonNull Set<@NonNull ContainerClass> getDetailedContainerClasses(org.eclipse.ocl.pivot.@NonNull Class type) {
Type primaryType = mManager.getPrimaryClass(type);
Set<@NonNull ContainerClass> containerClasses = class2detailedContainerClasses.get(primaryType);
return ClassUtil.nonNullState(containerClasses == null ? Collections.<@NonNull ContainerClass>emptySet()
- : Collections.<@NonNull ContainerClass>unmodifiableSet(containerClasses));
+ : Collections.<@NonNull ContainerClass>unmodifiableSet(containerClasses));
}
}

Back to the top