Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrbrooks2010-09-15 15:27:40 -0400
committerRyan D. Brooks2010-09-15 15:27:40 -0400
commit36e52c037cb795e20e8f381e8d3a6f1b6877ca04 (patch)
treece85d8d0c6f588a2554a1ddbc3d26e241a9f0320 /plugins
parent0b653a4f5aea8e98ffbeca962ba7f33db06386e0 (diff)
downloadorg.eclipse.osee-36e52c037cb795e20e8f381e8d3a6f1b6877ca04.tar.gz
org.eclipse.osee-36e52c037cb795e20e8f381e8d3a6f1b6877ca04.tar.xz
org.eclipse.osee-36e52c037cb795e20e8f381e8d3a6f1b6877ca04.zip
refactor: Utilize utility method Conditions.checkNotNull instaed of in-place code
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/search/ArtifactTypeSearchItem.java6
-rw-r--r--plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/search/ArtifactTypesSearchItem.java6
-rw-r--r--plugins/org.eclipse.osee.framework.branch.management/src/org/eclipse/osee/framework/branch/management/exchange/resource/ZipBinaryResource.java13
-rw-r--r--plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/util/Conditions.java7
4 files changed, 15 insertions, 17 deletions
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/search/ArtifactTypeSearchItem.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/search/ArtifactTypeSearchItem.java
index b7965f20f9..1cb11bfe19 100644
--- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/search/ArtifactTypeSearchItem.java
+++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/search/ArtifactTypeSearchItem.java
@@ -13,8 +13,8 @@ package org.eclipse.osee.ats.world.search;
import java.util.Collection;
import org.eclipse.osee.ats.util.AtsUtil;
import org.eclipse.osee.framework.core.data.IArtifactType;
-import org.eclipse.osee.framework.core.exception.OseeArgumentException;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.util.Conditions;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
import org.eclipse.osee.framework.ui.skynet.FrameworkImage;
@@ -38,9 +38,7 @@ public class ArtifactTypeSearchItem extends WorldUISearchItem {
@Override
public Collection<Artifact> performSearch(SearchType searchType) throws OseeCoreException {
- if (artifactType == null) {
- throw new OseeArgumentException("Inavlid search \"" + getName() + "\"");
- }
+ Conditions.checkNotNull(artifactType, getName());
return ArtifactQuery.getArtifactListFromType(artifactType, AtsUtil.getAtsBranch());
}
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/search/ArtifactTypesSearchItem.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/search/ArtifactTypesSearchItem.java
index 0503cbadae..1d6209be3e 100644
--- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/search/ArtifactTypesSearchItem.java
+++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/search/ArtifactTypesSearchItem.java
@@ -14,8 +14,8 @@ import static org.eclipse.osee.framework.core.enums.DeletionFlag.EXCLUDE_DELETED
import java.util.Collection;
import org.eclipse.osee.ats.util.AtsUtil;
import org.eclipse.osee.framework.core.data.IArtifactType;
-import org.eclipse.osee.framework.core.exception.OseeArgumentException;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.util.Conditions;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
import org.eclipse.osee.framework.ui.skynet.FrameworkImage;
@@ -39,9 +39,7 @@ public class ArtifactTypesSearchItem extends WorldUISearchItem {
@Override
public Collection<Artifact> performSearch(SearchType searchType) throws OseeCoreException {
- if (artifactTypes == null || artifactTypes.isEmpty()) {
- throw new OseeArgumentException("Inavlid search \"" + getName() + "\"");
- }
+ Conditions.checkNotNullOrEmpty(artifactTypes, getName());
return ArtifactQuery.getArtifactListFromTypes(artifactTypes, AtsUtil.getAtsBranch(), EXCLUDE_DELETED);
}
diff --git a/plugins/org.eclipse.osee.framework.branch.management/src/org/eclipse/osee/framework/branch/management/exchange/resource/ZipBinaryResource.java b/plugins/org.eclipse.osee.framework.branch.management/src/org/eclipse/osee/framework/branch/management/exchange/resource/ZipBinaryResource.java
index 1ced5a1cfb..c5ac60f4bf 100644
--- a/plugins/org.eclipse.osee.framework.branch.management/src/org/eclipse/osee/framework/branch/management/exchange/resource/ZipBinaryResource.java
+++ b/plugins/org.eclipse.osee.framework.branch.management/src/org/eclipse/osee/framework/branch/management/exchange/resource/ZipBinaryResource.java
@@ -18,6 +18,7 @@ import java.io.InputStream;
import java.net.URI;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.exception.OseeExceptions;
+import org.eclipse.osee.framework.core.util.Conditions;
import org.eclipse.osee.framework.jdk.core.util.Lib;
import org.eclipse.osee.framework.resource.management.IResource;
import org.eclipse.osee.framework.resource.management.IResourceLocator;
@@ -30,19 +31,13 @@ public final class ZipBinaryResource implements IResource {
private final IResourceLocator locator;
private final File entry;
- public ZipBinaryResource(File entry, IResourceLocator locator) {
- checkNotNull("FileEntry", entry);
- checkNotNull("IResourceLocator", locator);
+ public ZipBinaryResource(File entry, IResourceLocator locator) throws OseeCoreException {
+ Conditions.checkNotNull(entry, "FileEntry");
+ Conditions.checkNotNull(locator, "IResourceLocator");
this.entry = entry;
this.locator = locator;
}
- private void checkNotNull(String argName, Object object) {
- if (object == null) {
- throw new IllegalArgumentException(String.format("Argument was null - [%s]", argName));
- }
- }
-
@Override
public InputStream getContent() throws OseeCoreException {
InputStream inputStream = null;
diff --git a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/util/Conditions.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/util/Conditions.java
index cf948ff6ac..471f401cf2 100644
--- a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/util/Conditions.java
+++ b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/util/Conditions.java
@@ -45,6 +45,13 @@ public final class Conditions {
}
}
+ public static void checkNotNullOrEmpty(Collection<? extends Object> collection, String objectName) throws OseeCoreException {
+ checkNotNull(collection, objectName);
+ if (collection.isEmpty()) {
+ throw new OseeArgumentException("%s cannot be empty", objectName);
+ }
+ }
+
public static void checkNotNullOrEmpty(String object, String objectName, String details, Object... data) throws OseeCoreException {
checkNotNull(object, objectName);
if (object.length() == 0) {

Back to the top