Skip to content

Commit

Permalink
[FELIX-5997] Remove hashcode and equals from AbstractCapabilityRequir…
Browse files Browse the repository at this point in the history
…ement to deal with fragment. This closes #164

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1848700 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
jbonofre committed Dec 11, 2018
1 parent 71d3eb8 commit f7ecd36
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,23 +76,6 @@ public Resource getResource() {
return resource;
}


@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
AbstractCapabilityRequirement that = (AbstractCapabilityRequirement) o;
return Objects.equals(resource, that.resource) &&
Objects.equals(namespace, that.namespace) &&
Objects.equals(attributes, that.attributes) &&
Objects.equals(directives, that.directives);
}

@Override
public int hashCode() {
return Objects.hash(resource, namespace, attributes, directives);
}

@Override
public String toString() {
return ResourceUtils.toString(getResource(), getNamespace(), getAttributes(), getDirectives());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,10 @@ public void testCapabilityEqualsHashcode() {
assertEquals(res, c1.getResource());

CapabilityImpl c2 = new CapabilityImpl(res, "org.foo.bar", dirs, attrs);
assertEquals(c1, c2);
assertEquals(c1.hashCode(), c2.hashCode());
assertEquals(c1.toString(), c2.toString());

CapabilityImpl c3 = new CapabilityImpl(res, "org.foo.bar2", dirs, attrs);
assertNotEquals(c1, c3);
assertFalse(c1.hashCode() == c3.hashCode());
assertNotEquals(c1.toString(), c3.toString());
}

public void testCopyCapability() {
Expand All @@ -71,6 +69,6 @@ public void testCopyCapability() {
assertNotEquals("Should not be equal, the resources are different", c, c2);

CapabilityImpl c3 = new CapabilityImpl(res, c);
assertEquals(c, c3);
assertEquals(c.toString(), c3.toString());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,10 @@ public void testRequirementEqualsHashcode() {
assertEquals(res, r1.getResource());

RequirementImpl r2 = new RequirementImpl(res, "org.foo.bar", dirs, attrs);
assertEquals(r1, r2);
assertEquals(r1.hashCode(), r2.hashCode());
assertEquals(r1.toString(), r2.toString());

RequirementImpl r3 = new RequirementImpl(res, "org.foo.bar2", dirs, attrs);
assertNotEquals(r1, r3);
assertNotEquals(r1.hashCode(), r3.hashCode());
assertNotEquals(r1.toString(), r3.toString());
}

public void testRequirementFilter() {
Expand Down Expand Up @@ -86,7 +84,7 @@ public void testCopyRequirement() {
assertNotEquals("Should not be equal, the resources are different", r, r2);

RequirementImpl r3 = new RequirementImpl(res1, r);
assertEquals(r, r3);
assertEquals(r.toString(), r3.toString());
}

public void testOptional() {
Expand Down

0 comments on commit f7ecd36

Please sign in to comment.