Skip to content

Commit 8be1f41

Browse files
committed
Maven Resolver coords scheme #1
refactor + equals\hashCode added to CoordsMaven
1 parent ef6de08 commit 8be1f41

File tree

3 files changed

+28
-3
lines changed

3 files changed

+28
-3
lines changed

src/main/java/org/scm4j/commons/Coords.java renamed to src/main/java/org/scm4j/commons/coords/Coords.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
package org.scm4j.commons;
1+
package org.scm4j.commons.coords;
2+
3+
import org.scm4j.commons.Version;
24

35
public interface Coords {
46

src/main/java/org/scm4j/commons/coords/CoordsGradle.java

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import org.apache.commons.lang3.StringUtils;
44
import org.scm4j.commons.CommentedString;
5-
import org.scm4j.commons.Coords;
65
import org.scm4j.commons.Version;
76

87
public class CoordsGradle implements Coords {

src/main/java/org/scm4j/commons/coords/CoordsMaven.java

+25-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import org.apache.commons.lang3.StringUtils;
44
import org.scm4j.commons.CommentedString;
5-
import org.scm4j.commons.Coords;
65
import org.scm4j.commons.Version;
76

87
public class CoordsMaven implements Coords {
@@ -93,4 +92,29 @@ public Version getVersion() {
9392
public String getName() {
9493
return groupId + artifactId;
9594
}
95+
96+
@Override
97+
public int hashCode() {
98+
final int prime = 31;
99+
int result = 1;
100+
result = prime * result + ((coordsStringNoComment == null) ? 0 : coordsStringNoComment.hashCode());
101+
return result;
102+
}
103+
104+
@Override
105+
public boolean equals(Object obj) {
106+
if (this == obj)
107+
return true;
108+
if (obj == null)
109+
return false;
110+
if (getClass() != obj.getClass())
111+
return false;
112+
CoordsMaven other = (CoordsMaven) obj;
113+
if (coordsStringNoComment == null) {
114+
if (other.coordsStringNoComment != null)
115+
return false;
116+
} else if (!coordsStringNoComment.equals(other.coordsStringNoComment))
117+
return false;
118+
return true;
119+
}
96120
}

0 commit comments

Comments
 (0)