Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjphillips2010-07-21 10:14:14 -0400
committerjphillips2010-07-21 10:14:14 -0400
commite989c4b0539214b3792b1bcd0b17a5721c48aab1 (patch)
tree808f41a158ee2f01f370a93856e1eb2435ee117a
parent6e5ef23353be1c4e957718a866e996c04097a0e1 (diff)
downloadorg.eclipse.osee-e989c4b0539214b3792b1bcd0b17a5721c48aab1.tar.gz
org.eclipse.osee-e989c4b0539214b3792b1bcd0b17a5721c48aab1.tar.xz
org.eclipse.osee-e989c4b0539214b3792b1bcd0b17a5721c48aab1.zip
Added generics to AccessCollector class
-rw-r--r--plugins/org.eclipse.osee.framework.access.test/src/org/eclipse/osee/framework/access/test/internal/AccessCollectorTest.java28
-rw-r--r--plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/access/exp/AccessCollector.java16
2 files changed, 22 insertions, 22 deletions
diff --git a/plugins/org.eclipse.osee.framework.access.test/src/org/eclipse/osee/framework/access/test/internal/AccessCollectorTest.java b/plugins/org.eclipse.osee.framework.access.test/src/org/eclipse/osee/framework/access/test/internal/AccessCollectorTest.java
index fadc0a8722..805ec706e5 100644
--- a/plugins/org.eclipse.osee.framework.access.test/src/org/eclipse/osee/framework/access/test/internal/AccessCollectorTest.java
+++ b/plugins/org.eclipse.osee.framework.access.test/src/org/eclipse/osee/framework/access/test/internal/AccessCollectorTest.java
@@ -45,14 +45,14 @@ public class AccessCollectorTest {
filters.add(phoneTypeFilter);
filters.add(wordTypeFilter);
- AccessCollector collector = new AccessCollector(filters);
- Assert.assertTrue(collector.getAttributeTypes(basicArtifact, Arrays.asList(wordAttrType, phoneType),
+ AccessCollector<IAttributeType> collector = new AccessCollector<IAttributeType>(filters);
+ Assert.assertTrue(collector.getAttributeTypesToMatch(basicArtifact, Arrays.asList(wordAttrType, phoneType),
PermissionEnum.WRITE).size() == 1);
- Assert.assertTrue(collector.getAttributeTypes(basicArtifact, Arrays.asList(wordAttrType, phoneType),
+ Assert.assertTrue(collector.getAttributeTypesToMatch(basicArtifact, Arrays.asList(wordAttrType, phoneType),
PermissionEnum.READ).size() == 2);
- Assert.assertTrue(collector.getAttributeTypes(basicArtifact, Arrays.asList(wordAttrType, phoneType),
+ Assert.assertTrue(collector.getAttributeTypesToMatch(basicArtifact, Arrays.asList(wordAttrType, phoneType),
PermissionEnum.DENY).isEmpty());
- Assert.assertTrue(collector.getAttributeTypes(basicArtifact, Arrays.asList(wordAttrType, phoneType),
+ Assert.assertTrue(collector.getAttributeTypesToMatch(basicArtifact, Arrays.asList(wordAttrType, phoneType),
PermissionEnum.FULLACCESS).isEmpty());
}
@@ -71,14 +71,14 @@ public class AccessCollectorTest {
filters.add(phoneTypeFilter);
filters.add(wordTypeFilter);
- AccessCollector collector = new AccessCollector(filters);
- Assert.assertTrue(collector.getAttributeTypes(basicArtifact, Arrays.asList(wordAttrType, phoneType),
+ AccessCollector<IAttributeType> collector = new AccessCollector<IAttributeType>(filters);
+ Assert.assertTrue(collector.getAttributeTypesToMatch(basicArtifact, Arrays.asList(wordAttrType, phoneType),
PermissionEnum.WRITE).size() == 1);
- Assert.assertTrue(collector.getAttributeTypes(basicArtifact, Arrays.asList(wordAttrType, phoneType),
+ Assert.assertTrue(collector.getAttributeTypesToMatch(basicArtifact, Arrays.asList(wordAttrType, phoneType),
PermissionEnum.READ).size() == 2);
- Assert.assertTrue(collector.getAttributeTypes(basicArtifact, Arrays.asList(wordAttrType, phoneType),
+ Assert.assertTrue(collector.getAttributeTypesToMatch(basicArtifact, Arrays.asList(wordAttrType, phoneType),
PermissionEnum.DENY).isEmpty());
- Assert.assertTrue(collector.getAttributeTypes(basicArtifact, Arrays.asList(wordAttrType, phoneType),
+ Assert.assertTrue(collector.getAttributeTypesToMatch(basicArtifact, Arrays.asList(wordAttrType, phoneType),
PermissionEnum.FULLACCESS).isEmpty());
}
@@ -96,13 +96,13 @@ public class AccessCollectorTest {
filters.add(branchAccessFilter);
AccessCollector collector = new AccessCollector(filters);
- Assert.assertTrue(collector.getAttributeTypes(basicArtifact, Arrays.asList(wordAttrType, phoneType),
+ Assert.assertTrue(collector.getAttributeTypesToMatch(basicArtifact, Arrays.asList(wordAttrType, phoneType),
PermissionEnum.WRITE).size() == 2);
- Assert.assertTrue(collector.getAttributeTypes(basicArtifact, Arrays.asList(wordAttrType, phoneType),
+ Assert.assertTrue(collector.getAttributeTypesToMatch(basicArtifact, Arrays.asList(wordAttrType, phoneType),
PermissionEnum.READ).size() == 2);
- Assert.assertTrue(collector.getAttributeTypes(basicArtifact, Arrays.asList(wordAttrType, phoneType),
+ Assert.assertTrue(collector.getAttributeTypesToMatch(basicArtifact, Arrays.asList(wordAttrType, phoneType),
PermissionEnum.DENY).isEmpty());
- Assert.assertTrue(collector.getAttributeTypes(basicArtifact, Arrays.asList(wordAttrType, phoneType),
+ Assert.assertTrue(collector.getAttributeTypesToMatch(basicArtifact, Arrays.asList(wordAttrType, phoneType),
PermissionEnum.FULLACCESS).isEmpty());
}
}
diff --git a/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/access/exp/AccessCollector.java b/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/access/exp/AccessCollector.java
index a444c0447b..21ecda833d 100644
--- a/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/access/exp/AccessCollector.java
+++ b/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/access/exp/AccessCollector.java
@@ -8,14 +8,14 @@ package org.eclipse.osee.framework.core.model.access.exp;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
-import org.eclipse.osee.framework.core.data.IAttributeType;
import org.eclipse.osee.framework.core.enums.PermissionEnum;
import org.eclipse.osee.framework.core.model.IBasicArtifact;
/**
* @author Jeff C. Phillips
+ * @param <T>
*/
-public class AccessCollector {
+public class AccessCollector<T> {
private final Collection<IAccessFilter> filters;
@@ -23,16 +23,16 @@ public class AccessCollector {
this.filters = filters;
}
- public List<IAttributeType> getAttributeTypes(IBasicArtifact<?> artifact, Collection<IAttributeType> attrs, PermissionEnum permission) {
- List<IAttributeType> validAttrs = new ArrayList<IAttributeType>();
+ public List<T> getAttributeTypesToMatch(IBasicArtifact<?> artifact, Collection<T> toCheck, PermissionEnum permission) {
+ List<T> validObjects = new ArrayList<T>();
AccessFilterChain chain = new AccessFilterChain();
chain.addAll(filters);
- for (IAttributeType type : attrs) {
- if (chain.doFilter(artifact, type, permission, null)) {
- validAttrs.add(type);
+ for (T object : toCheck) {
+ if (chain.doFilter(artifact, object, permission, null)) {
+ validObjects.add(object);
}
}
- return validAttrs;
+ return validObjects;
}
}

Back to the top