11.08., 9:00 - 11:00: Due to updates GitLab will be unavailable for some minutes between 09:00 and 11:00.

Commit f0a486d1 authored by Tobias Meggendorfer's avatar Tobias Meggendorfer

Add sanity check to equals of ValuationSet and EquivalenceClass

parent b881ca07
......@@ -325,9 +325,10 @@ final class EquivalenceFactory extends GcManagedFactory<BddEquivalenceClass>
}
/**
* This class does not override `equals` and `hashCode`, since GcManagedFactory ensures
* This class does not implement a proper `equals` and `hashCode`, since GcManagedFactory ensures
* uniqueness.
*/
@SuppressWarnings("PMD.OverrideBothEqualsAndHashcode") // We only have a "bogus" assert equals
static final class BddEquivalenceClass implements BddNode, EquivalenceClass {
private final EquivalenceFactory factory;
private final int node;
......@@ -541,5 +542,13 @@ final class EquivalenceFactory extends GcManagedFactory<BddEquivalenceClass>
return truenessCache;
}
@Override
public boolean equals(Object obj) {
// Check that we are not comparing classes of different factories
assert !(obj instanceof EquivalenceClass) || ((EquivalenceClass) obj).factory() == factory();
return this == obj;
}
}
}
......@@ -357,9 +357,10 @@ final class ValuationFactory extends GcManagedFactory<BddValuationSet>
}
/**
* This class does not override `equals` and `hashCode`, since GcManagedFactory ensures
* This class does not implement a proper `equals` and `hashCode`, since GcManagedFactory ensures
* uniqueness.
*/
@SuppressWarnings("PMD.OverrideBothEqualsAndHashcode") // We only have a "bogus" assert equals
static final class BddValuationSet extends ValuationSet implements BddNode {
private final ValuationFactory factory;
private final int node;
......@@ -418,5 +419,13 @@ final class ValuationFactory extends GcManagedFactory<BddValuationSet>
public BigInteger size() {
return factory.bdd.countSatisfyingAssignments(node);
}
@Override
public boolean equals(Object obj) {
// Check that we are not comparing classes of different factories
assert !(obj instanceof ValuationSet) || ((ValuationSet) obj).factory() == factory();
return this == obj;
}
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment