Skip to content

Commit

Permalink
add equals and hashcode for ratioTapChangerImpl
Browse files Browse the repository at this point in the history
Signed-off-by: Etienne LESOT <[email protected]>
  • Loading branch information
EtienneLt committed Oct 29, 2024
1 parent 516b0af commit 65603be
Showing 1 changed file with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -180,4 +180,32 @@ public RatioTapChanger setTargetV(double targetV) {
public static void validateStep(TapChangerStepAttributes step, TapChangerParent parent) {
AbstractTapChanger.validateStep(step, parent);
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
RatioTapChangerImpl that = (RatioTapChangerImpl) o;
// check phase tap changer are on same leg
if (!Objects.equals(that.getTransformer().getClass(), getTransformer().getClass())) {
return false;
}
if (that.getTransformer() instanceof ThreeWindingsTransformerImpl &&
!Objects.equals(((ThreeWindingsTransformerImpl.LegImpl) parent).getSide(),
((ThreeWindingsTransformerImpl.LegImpl) that.getParent()).getSide())) {
return false;
}
return Objects.equals(getTransformer().getId(), that.getTransformer().getId()) &&
Objects.equals(getRegulationMode(), that.getRegulationMode()) &&
Objects.equals(getRegulationValue(), that.getRegulationValue());
}

@Override
public int hashCode() {
return Objects.hash(getParent(), getTransformer().getId(), getRegulationMode(), getRegulationValue());
}
}

0 comments on commit 65603be

Please sign in to comment.