diff options
author | Sébastien Lesaint <sebastien.lesaint@sonarsource.com> | 2015-04-21 12:34:53 +0200 |
---|---|---|
committer | Sébastien Lesaint <sebastien.lesaint@sonarsource.com> | 2015-04-21 12:35:21 +0200 |
commit | ad0278f3933bb806cbedf91b20e852562e663a1d (patch) | |
tree | 08d586a2b6cfc5506ba10d6c66766530fbca6c2a | |
parent | b03513b58f4858a9932f442b0ed55f4cdcd34b42 (diff) | |
download | sonarqube-ad0278f3933bb806cbedf91b20e852562e663a1d.tar.gz sonarqube-ad0278f3933bb806cbedf91b20e852562e663a1d.zip |
having a go at quality issues on singleton enum Predicates
3 files changed, 11 insertions, 19 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/plugins/ServerPluginJarsInstaller.java b/server/sonar-server/src/main/java/org/sonar/server/plugins/ServerPluginJarsInstaller.java index be8146b73f1..cbed2cb3602 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/plugins/ServerPluginJarsInstaller.java +++ b/server/sonar-server/src/main/java/org/sonar/server/plugins/ServerPluginJarsInstaller.java @@ -33,7 +33,7 @@ import org.sonar.core.plugins.DefaultPluginMetadata; import org.sonar.server.platform.DefaultServerFileSystem; import org.sonar.updatecenter.common.PluginReferential; -import javax.annotation.Nullable; +import javax.annotation.Nonnull; import java.io.File; import java.io.IOException; import java.util.Arrays; @@ -44,7 +44,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.collect.Iterables.transform; import static com.google.common.collect.Lists.newArrayList; import static java.lang.String.format; @@ -280,8 +279,8 @@ public class ServerPluginJarsInstaller { INSTANCE; @Override - public String apply(@Nullable File file) { - return checkNotNull(file).getName(); + public String apply(@Nonnull File file) { + return file.getName(); } } } diff --git a/server/sonar-server/src/main/java/org/sonar/server/plugins/ws/PluginWSCommons.java b/server/sonar-server/src/main/java/org/sonar/server/plugins/ws/PluginWSCommons.java index 4a81554765c..176f369e727 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/plugins/ws/PluginWSCommons.java +++ b/server/sonar-server/src/main/java/org/sonar/server/plugins/ws/PluginWSCommons.java @@ -24,7 +24,7 @@ import com.google.common.collect.Ordering; import org.sonar.api.platform.PluginMetadata; import org.sonar.api.utils.text.JsonWriter; -import javax.annotation.Nullable; +import javax.annotation.Nonnull; public class PluginWSCommons { static final String PROPERTY_KEY = "key"; @@ -83,10 +83,7 @@ public class PluginWSCommons { INSTANCE; @Override - public String apply(@Nullable PluginMetadata input) { - if (input == null) { - return null; - } + public String apply(@Nonnull PluginMetadata input) { return input.getName(); } } @@ -95,10 +92,7 @@ public class PluginWSCommons { INSTANCE; @Override - public String apply(@Nullable PluginMetadata input) { - if (input == null) { - return null; - } + public String apply(@Nonnull PluginMetadata input) { return input.getKey(); } } diff --git a/sonar-core/src/main/java/org/sonar/core/plugins/PluginJarInstaller.java b/sonar-core/src/main/java/org/sonar/core/plugins/PluginJarInstaller.java index ff90f7f1274..5af5f9c754f 100644 --- a/sonar-core/src/main/java/org/sonar/core/plugins/PluginJarInstaller.java +++ b/sonar-core/src/main/java/org/sonar/core/plugins/PluginJarInstaller.java @@ -25,13 +25,12 @@ import org.sonar.api.ServerComponent; import org.sonar.api.utils.SonarException; import org.sonar.updatecenter.common.PluginManifest; +import javax.annotation.Nonnull; import javax.annotation.Nullable; import java.io.File; import java.io.IOException; import java.util.Arrays; -import static com.google.common.base.Preconditions.checkNotNull; - public abstract class PluginJarInstaller implements BatchComponent, ServerComponent { protected static final String FAIL_TO_INSTALL_PLUGIN = "Fail to install plugin: "; @@ -95,14 +94,14 @@ public abstract class PluginJarInstaller implements BatchComponent, ServerCompon private final Function<File, DefaultPluginMetadata> jarFileToCorePlugin = new Function<File, DefaultPluginMetadata>() { @Override - public DefaultPluginMetadata apply(@Nullable File file) { - return extractMetadata(checkNotNull(file), true); + public DefaultPluginMetadata apply(@Nonnull File file) { + return extractMetadata(file, true); } }; private final Function<File, DefaultPluginMetadata> jarFileToPlugin = new Function<File, DefaultPluginMetadata>() { @Override - public DefaultPluginMetadata apply(@Nullable File file) { - return extractMetadata(checkNotNull(file), false); + public DefaultPluginMetadata apply(@Nonnull File file) { + return extractMetadata(file, false); } }; } |