Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FELIX-5997] Remove hashcode and equals from AbstractCapabilityRequirement to deal with fragment #164

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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