Skip to content

Commit 87e536e

Browse files
CopilotbedaHovorka
andcommitted
Replace .equals() calls with == operator for idiomatic Kotlin
- Convert Point.equals() to == in DefaultContext.kt (3 occurrences) - Convert Point.equals() to != in Cell.kt (1 occurrence) - All null-safety assertions remain unchanged - All tests pass (629/659 active tests) Co-authored-by: bedaHovorka <5263405+bedaHovorka@users.noreply.github.com>
1 parent e1f3b39 commit 87e536e

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

src/main/kotlin/cz/vutbr/fit/interlockSim/context/DefaultContext.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -388,13 +388,13 @@ abstract class DefaultContext :
388388
points: MutableList<Point>
389389
): Boolean {
390390
assert(key1 != null && key2 != null && p1 != null && p2 != null)
391-
assert(!key1.equals(p1) && !key2.equals(p2) && !key1.equals(p2) && !key2.equals(p1))
391+
assert(key1 != p1 && key2 != p2 && key1 != p2 && key2 != p1)
392392

393393
// Make mutable copies since we need to modify them for the algorithm
394394
var p1Mut = p1
395395
var p2Mut = p2
396396

397-
if (p1Mut.equals(p2Mut)) {
397+
if (p1Mut == p2Mut) {
398398
points.add(p1Mut) // snad je naklonovany
399399
return false
400400
}
@@ -429,7 +429,7 @@ abstract class DefaultContext :
429429
for (x in p1Mut.x..p2Mut.x) {
430430
val newPoint = if (!swapped) Point(x, y) else Point(y, x)
431431

432-
if (newPoint.equals(key1) || newPoint.equals(key2) || used(newPoint)) {
432+
if (newPoint == key1 || newPoint == key2 || used(newPoint)) {
433433
points.clear()
434434
return b
435435
}

src/main/kotlin/cz/vutbr/fit/interlockSim/objects/cells/Cell.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ interface Cell {
8383
fun transform(from: Point): Point {
8484
assert(from != null)
8585
val tr = Point(from.x + dx, from.y + dy)
86-
assert(!from.equals(tr)) { this }
86+
assert(from != tr) { this }
8787
return tr
8888
}
8989

0 commit comments

Comments
 (0)