From 910c937a30dcf3e11fb8a0cf48f6abdc804e889a Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Sun, 30 Sep 2012 09:48:17 +0200 Subject: [PATCH] indent --- .../sonia/scm/plugin/PluginInformation.java | 115 ++++++++++-------- .../api/rest/resources/PluginResource.java | 12 +- 2 files changed, 74 insertions(+), 53 deletions(-) diff --git a/scm-core/src/main/java/sonia/scm/plugin/PluginInformation.java b/scm-core/src/main/java/sonia/scm/plugin/PluginInformation.java index 47363b9895..e67fe65dfb 100644 --- a/scm-core/src/main/java/sonia/scm/plugin/PluginInformation.java +++ b/scm-core/src/main/java/sonia/scm/plugin/PluginInformation.java @@ -128,56 +128,56 @@ public class PluginInformation implements Validateable, Cloneable, Serializable final PluginInformation other = (PluginInformation) obj; if ((this.artifactId == null) - ? (other.artifactId != null) - : !this.artifactId.equals(other.artifactId)) + ? (other.artifactId != null) + : !this.artifactId.equals(other.artifactId)) { return false; } if ((this.author == null) - ? (other.author != null) - : !this.author.equals(other.author)) + ? (other.author != null) + : !this.author.equals(other.author)) { return false; } if ((this.category == null) - ? (other.category != null) - : !this.category.equals(other.category)) + ? (other.category != null) + : !this.category.equals(other.category)) { return false; } if ((this.condition != other.condition) - && ((this.condition == null) ||!this.condition.equals(other.condition))) + && ((this.condition == null) ||!this.condition.equals(other.condition))) { return false; } if ((this.description == null) - ? (other.description != null) - : !this.description.equals(other.description)) + ? (other.description != null) + : !this.description.equals(other.description)) { return false; } if ((this.groupId == null) - ? (other.groupId != null) - : !this.groupId.equals(other.groupId)) + ? (other.groupId != null) + : !this.groupId.equals(other.groupId)) { return false; } if ((this.name == null) - ? (other.name != null) - : !this.name.equals(other.name)) + ? (other.name != null) + : !this.name.equals(other.name)) { return false; } if ((this.screenshots != other.screenshots) - && ((this.screenshots == null) - ||!this.screenshots.equals(other.screenshots))) + && ((this.screenshots == null) + ||!this.screenshots.equals(other.screenshots))) { return false; } @@ -188,22 +188,22 @@ public class PluginInformation implements Validateable, Cloneable, Serializable } if ((this.url == null) - ? (other.url != null) - : !this.url.equals(other.url)) + ? (other.url != null) + : !this.url.equals(other.url)) { return false; } if ((this.version == null) - ? (other.version != null) - : !this.version.equals(other.version)) + ? (other.version != null) + : !this.version.equals(other.version)) { return false; } if ((this.wiki == null) - ? (other.wiki != null) - : !this.wiki.equals(other.wiki)) + ? (other.wiki != null) + : !this.wiki.equals(other.wiki)) { return false; } @@ -223,41 +223,41 @@ public class PluginInformation implements Validateable, Cloneable, Serializable int hash = 5; hash = 79 * hash + ((this.artifactId != null) - ? this.artifactId.hashCode() - : 0); + ? this.artifactId.hashCode() + : 0); hash = 79 * hash + ((this.author != null) - ? this.author.hashCode() - : 0); + ? this.author.hashCode() + : 0); hash = 79 * hash + ((this.category != null) - ? this.category.hashCode() - : 0); + ? this.category.hashCode() + : 0); hash = 79 * hash + ((this.condition != null) - ? this.condition.hashCode() - : 0); + ? this.condition.hashCode() + : 0); hash = 79 * hash + ((this.description != null) - ? this.description.hashCode() - : 0); + ? this.description.hashCode() + : 0); hash = 79 * hash + ((this.groupId != null) - ? this.groupId.hashCode() - : 0); + ? this.groupId.hashCode() + : 0); hash = 79 * hash + ((this.name != null) - ? this.name.hashCode() - : 0); + ? this.name.hashCode() + : 0); hash = 79 * hash + ((this.screenshots != null) - ? this.screenshots.hashCode() - : 0); + ? this.screenshots.hashCode() + : 0); hash = 79 * hash + ((this.state != null) - ? this.state.hashCode() - : 0); + ? this.state.hashCode() + : 0); hash = 79 * hash + ((this.url != null) - ? this.url.hashCode() - : 0); + ? this.url.hashCode() + : 0); hash = 79 * hash + ((this.version != null) - ? this.version.hashCode() - : 0); + ? this.version.hashCode() + : 0); hash = 79 * hash + ((this.wiki != null) - ? this.wiki.hashCode() - : 0); + ? this.wiki.hashCode() + : 0); return hash; } @@ -337,12 +337,31 @@ public class PluginInformation implements Validateable, Cloneable, Serializable * @return */ public String getId() + { + return getId(true); + } + + /** + * Method description + * + * + * @param withVersion + * + * @return + * @since 1.21 + */ + public String getId(boolean withVersion) { StringBuilder id = new StringBuilder(groupId); - id.append(":").append(artifactId).append(":"); + id.append(":").append(artifactId); - return id.append(version).toString(); + if (withVersion) + { + id.append(":").append(version); + } + + return id.toString(); } /** @@ -421,7 +440,7 @@ public class PluginInformation implements Validateable, Cloneable, Serializable public boolean isValid() { return Util.isNotEmpty(groupId) && Util.isNotEmpty(artifactId) - && Util.isNotEmpty(name) && Util.isNotEmpty(version); + && Util.isNotEmpty(name) && Util.isNotEmpty(version); } //~--- set methods ---------------------------------------------------------- diff --git a/scm-webapp/src/main/java/sonia/scm/api/rest/resources/PluginResource.java b/scm-webapp/src/main/java/sonia/scm/api/rest/resources/PluginResource.java index e94fd70e42..2ad44c817f 100644 --- a/scm-webapp/src/main/java/sonia/scm/api/rest/resources/PluginResource.java +++ b/scm-webapp/src/main/java/sonia/scm/api/rest/resources/PluginResource.java @@ -35,6 +35,7 @@ package sonia.scm.api.rest.resources; //~--- non-JDK imports -------------------------------------------------------- +import com.google.common.collect.Lists; import com.google.inject.Inject; import com.google.inject.Singleton; @@ -56,7 +57,6 @@ import com.sun.jersey.multipart.FormDataParam; import java.io.IOException; import java.io.InputStream; -import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.Iterator; @@ -295,9 +295,11 @@ public class PluginResource @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public Collection getOverview() { - List plugins = new ArrayList( - pluginManager.get( - OverviewPluginFilter.INSTANCE)); + //J- + List plugins = Lists.newArrayList( + pluginManager.get(OverviewPluginFilter.INSTANCE) + ); + //J+ Collections.sort(plugins, PluginInformationComparator.INSTANCE); @@ -307,7 +309,7 @@ public class PluginResource while (it.hasNext()) { PluginInformation pi = it.next(); - String id = pi.getGroupId().concat(":").concat(pi.getArtifactId()); + String id = pi.getId(false); if ((last != null) && id.equals(last)) {