summaryrefslogtreecommitdiff
path: root/plugins/maven/src/main/java/org/jetbrains/idea
diff options
context:
space:
mode:
authorTor Norbye <tnorbye@google.com>2013-08-13 10:39:52 -0700
committerTor Norbye <tnorbye@google.com>2013-08-13 10:39:52 -0700
commitd1129abbe4dc0ce9bbad9118a35a85dbebc8758f (patch)
tree9cc628ccfcfb445bddb0214eb0dd2a790bc08789 /plugins/maven/src/main/java/org/jetbrains/idea
parent9fdfa377b20b105e3a9907d32434787f75781c35 (diff)
downloadidea-d1129abbe4dc0ce9bbad9118a35a85dbebc8758f.tar.gz
Snapshot 7e2655e04684ed009ba5dfe0caa809c5cabc6157 from master branch of git://git.jetbrains.org/idea/community.git
Change-Id: I44ab4f2b813b445edab5e1f32f66dc43693534b9
Diffstat (limited to 'plugins/maven/src/main/java/org/jetbrains/idea')
-rw-r--r--plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/DependencyId.java63
1 files changed, 63 insertions, 0 deletions
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/DependencyId.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/DependencyId.java
new file mode 100644
index 000000000000..f71270cd542b
--- /dev/null
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/DependencyId.java
@@ -0,0 +1,63 @@
+package org.jetbrains.idea.maven.dom;
+
+import com.intellij.openapi.util.text.StringUtil;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.idea.maven.dom.model.MavenDomDependency;
+
+/**
+* @author Sergey Evdokimov
+*/
+public class DependencyId {
+ private final String groupId;
+ private final String artifactId;
+ private final String type;
+ private final String classifier;
+
+ public DependencyId(@NotNull String groupId, @NotNull String artifactId, @Nullable String type, @Nullable String classifier) {
+ this.groupId = groupId;
+ this.artifactId = artifactId;
+ this.type = StringUtil.isEmpty(type) ? "jar" : type;
+ this.classifier = classifier;
+ }
+
+ @Nullable
+ public static DependencyId create(@NotNull MavenDomDependency dep) {
+ String groupId = dep.getGroupId().getStringValue();
+ if (StringUtil.isEmpty(groupId)) return null;
+
+ String artifactId = dep.getArtifactId().getStringValue();
+ if (StringUtil.isEmpty(artifactId)) return null;
+
+ //noinspection ConstantConditions
+ return new DependencyId(groupId, artifactId, dep.getType().getStringValue(), dep.getClassifier().getStringValue());
+ }
+
+ public boolean isValid() {
+ return StringUtil.isNotEmpty(groupId) && StringUtil.isNotEmpty(artifactId);
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (!(o instanceof DependencyId)) return false;
+
+ DependencyId id = (DependencyId)o;
+
+ if (artifactId != null ? !artifactId.equals(id.artifactId) : id.artifactId != null) return false;
+ if (classifier != null ? !classifier.equals(id.classifier) : id.classifier != null) return false;
+ if (groupId != null ? !groupId.equals(id.groupId) : id.groupId != null) return false;
+ if (!type.equals(id.type)) return false;
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = groupId != null ? groupId.hashCode() : 0;
+ result = 31 * result + (artifactId != null ? artifactId.hashCode() : 0);
+ result = 31 * result + type.hashCode();
+ result = 31 * result + (classifier != null ? classifier.hashCode() : 0);
+ return result;
+ }
+}