Simplify the implementation.
diff --git a/org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/bundleresources/BundleWebResource.java b/org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/bundleresources/BundleWebResource.java
index 093f8ef..bfecad6 100644
--- a/org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/bundleresources/BundleWebResource.java
+++ b/org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/bundleresources/BundleWebResource.java
@@ -150,7 +150,7 @@
private Set<String> getEntryPathsFromBundle(Bundle bundle) {
final Enumeration<String> ep = bundle.getEntryPaths(this.path);
- Set<String> paths = new HashSet<String>();
+ Set<String> paths = new HashSet<>();
if (ep != null) {
while (ep.hasMoreElements()) {
paths.add(ep.nextElement());
@@ -167,9 +167,8 @@
Map<BundleWebResource, URL> result = new HashMap<>();
result.put(createBundleEntry(finalPath), entryURL);
return result.entrySet().iterator().next();
- } else {
- return null;
}
+ return null;
}
/**
@@ -230,11 +229,10 @@
name = name.substring(index + 1);
}
- if (name.length() == 0) {
- return PATH_SEPARATOR;
- } else {
+ if (name.length() != 0) {
return name;
}
+ return PATH_SEPARATOR;
}
@Override
@@ -255,7 +253,7 @@
}
private List<Bundle> getFragments(Bundle bundle) {
- List<Bundle> fragments = new ArrayList<Bundle>();
+ List<Bundle> fragments = new ArrayList<>();
BundleRevision bundleRevision = bundle.adapt(BundleRevision.class);
if (bundleRevision != null) {
BundleWiring bundleWiring = bundleRevision.getWiring();
diff --git a/org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/bundleresources/BundleWebResourceSet.java b/org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/bundleresources/BundleWebResourceSet.java
index 55235ac..546f9cf 100644
--- a/org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/bundleresources/BundleWebResourceSet.java
+++ b/org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/bundleresources/BundleWebResourceSet.java
@@ -47,17 +47,12 @@
Entry<BundleWebResource, URL> entry = getNamedEntry(path.substring(webAppMount.length()));
if (entry != null) {
WebResource bundleEntry = entry.getKey();
- if (bundleEntry == null) {
- return new EmptyResource(root, path);
+ if (bundleEntry != null) {
+ return bundleEntry;
}
-
- return bundleEntry;
- } else {
- return new EmptyResource(root, path);
}
- } else {
- return new EmptyResource(root, path);
}
+ return new EmptyResource(root, path);
}
@Override
@@ -68,25 +63,16 @@
Entry<BundleWebResource, URL> entry = getNamedEntry(path.substring(webAppMount.length()));
if (entry != null) {
BundleWebResource bundleEntry = entry.getKey();
- if (bundleEntry == null) {
- return EMPTY_STRING_ARRAY;
- }
- List<BundleWebResource> list = bundleEntry.list();
- String[] result = null;
- if (list != null) {
- List<String> resources = new ArrayList<String>();
- for (BundleWebResource resource : list) {
- resources.add(resource.getName());
+ if (bundleEntry != null) {
+ List<BundleWebResource> list = bundleEntry.list();
+ if (list != null) {
+ List<String> resources = new ArrayList<>();
+ for (BundleWebResource resource : list) {
+ resources.add(resource.getName());
+ }
+ return resources.toArray(new String[resources.size()]);
}
- result = resources.toArray(new String[resources.size()]);
}
- if (result == null) {
- return EMPTY_STRING_ARRAY;
- } else {
- return result;
- }
- } else {
- return EMPTY_STRING_ARRAY;
}
} else {
if (!path.endsWith("/")) {
@@ -96,12 +82,11 @@
int i = webAppMount.indexOf('/', path.length());
if (i == -1) {
return new String[] { webAppMount.substring(path.length()) };
- } else {
- return new String[] { webAppMount.substring(path.length(), i) };
}
+ return new String[] { webAppMount.substring(path.length(), i) };
}
- return EMPTY_STRING_ARRAY;
}
+ return EMPTY_STRING_ARRAY;
}
@Override