Skip to content

Commit 514dddb

Browse files
committed
Sonar
1 parent a6d37f2 commit 514dddb

File tree

3 files changed

+95
-0
lines changed

3 files changed

+95
-0
lines changed

core/src/main/java/ai/timefold/solver/core/impl/score/stream/common/inliner/BendableBigDecimalScoreContext.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package ai.timefold.solver.core.impl.score.stream.common.inliner;
22

33
import java.math.BigDecimal;
4+
import java.util.Arrays;
5+
import java.util.Objects;
46

57
import ai.timefold.solver.core.api.score.buildin.bendablebigdecimal.BendableBigDecimalScore;
68
import ai.timefold.solver.core.impl.score.stream.common.AbstractConstraint;
@@ -116,6 +118,35 @@ public void undo() {
116118
public BendableBigDecimalScore toScore() {
117119
return BendableBigDecimalScore.of(hardImpacts, softImpacts);
118120
}
121+
122+
@Override
123+
public boolean equals(Object o) {
124+
if (this == o) {
125+
return true;
126+
}
127+
if (!(o instanceof ComplexImpact that)) {
128+
return false;
129+
}
130+
return Objects.equals(ctx, that.ctx) &&
131+
Objects.deepEquals(hardImpacts, that.hardImpacts) &&
132+
Objects.deepEquals(softImpacts, that.softImpacts);
133+
}
134+
135+
@Override
136+
public int hashCode() {
137+
var hash = 1;
138+
hash = 31 * hash + ctx.hashCode();
139+
hash = 31 * hash + Arrays.hashCode(hardImpacts);
140+
hash = 31 * hash + Arrays.hashCode(softImpacts);
141+
return hash;
142+
}
143+
144+
@Override
145+
public String toString() {
146+
return "Impact(hard: %s, soft: %s)"
147+
.formatted(Arrays.toString(hardImpacts), Arrays.toString(softImpacts));
148+
}
149+
119150
}
120151

121152
}

core/src/main/java/ai/timefold/solver/core/impl/score/stream/common/inliner/BendableLongScoreContext.java

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package ai.timefold.solver.core.impl.score.stream.common.inliner;
22

3+
import java.util.Arrays;
4+
import java.util.Objects;
5+
36
import ai.timefold.solver.core.api.score.buildin.bendablelong.BendableLongScore;
47
import ai.timefold.solver.core.impl.score.stream.common.AbstractConstraint;
58

@@ -110,6 +113,35 @@ public void undo() {
110113
public BendableLongScore toScore() {
111114
return BendableLongScore.of(hardImpacts, softImpacts);
112115
}
116+
117+
@Override
118+
public boolean equals(Object o) {
119+
if (this == o) {
120+
return true;
121+
}
122+
if (!(o instanceof ComplexImpact that)) {
123+
return false;
124+
}
125+
return Objects.equals(ctx, that.ctx) &&
126+
Objects.deepEquals(hardImpacts, that.hardImpacts) &&
127+
Objects.deepEquals(softImpacts, that.softImpacts);
128+
}
129+
130+
@Override
131+
public int hashCode() {
132+
var hash = 1;
133+
hash = 31 * hash + ctx.hashCode();
134+
hash = 31 * hash + Arrays.hashCode(hardImpacts);
135+
hash = 31 * hash + Arrays.hashCode(softImpacts);
136+
return hash;
137+
}
138+
139+
@Override
140+
public String toString() {
141+
return "Impact(hard: %s, soft: %s)"
142+
.formatted(Arrays.toString(hardImpacts), Arrays.toString(softImpacts));
143+
}
144+
113145
}
114146

115147
}

core/src/main/java/ai/timefold/solver/core/impl/score/stream/common/inliner/BendableScoreContext.java

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package ai.timefold.solver.core.impl.score.stream.common.inliner;
22

3+
import java.util.Arrays;
4+
import java.util.Objects;
5+
36
import ai.timefold.solver.core.api.score.buildin.bendable.BendableScore;
47
import ai.timefold.solver.core.impl.score.stream.common.AbstractConstraint;
58

@@ -108,6 +111,35 @@ public void undo() {
108111
public BendableScore toScore() {
109112
return BendableScore.of(hardImpacts, softImpacts);
110113
}
114+
115+
@Override
116+
public boolean equals(Object o) {
117+
if (this == o) {
118+
return true;
119+
}
120+
if (!(o instanceof ComplexImpact that)) {
121+
return false;
122+
}
123+
return Objects.equals(ctx, that.ctx) &&
124+
Objects.deepEquals(hardImpacts, that.hardImpacts) &&
125+
Objects.deepEquals(softImpacts, that.softImpacts);
126+
}
127+
128+
@Override
129+
public int hashCode() {
130+
var hash = 1;
131+
hash = 31 * hash + ctx.hashCode();
132+
hash = 31 * hash + Arrays.hashCode(hardImpacts);
133+
hash = 31 * hash + Arrays.hashCode(softImpacts);
134+
return hash;
135+
}
136+
137+
@Override
138+
public String toString() {
139+
return "Impact(hard: %s, soft: %s)"
140+
.formatted(Arrays.toString(hardImpacts), Arrays.toString(softImpacts));
141+
}
142+
111143
}
112144

113145
}

0 commit comments

Comments
 (0)