1 | package com.takenoko.layers.irrigation; | |
2 | ||
3 | import com.takenoko.vector.PositionVector; | |
4 | import com.takenoko.vector.Vector; | |
5 | import java.util.HashSet; | |
6 | import java.util.List; | |
7 | import java.util.Objects; | |
8 | import java.util.Set; | |
9 | import org.jetbrains.annotations.NotNull; | |
10 | ||
11 | /** This record represents an irrigation channel Position */ | |
12 | public class EdgePosition { | |
13 | private final Set<PositionVector> positions = new HashSet<>(); | |
14 | ||
15 | public EdgePosition( | |
16 | @NotNull PositionVector leftTilePosition, @NotNull PositionVector rightTilePosition) { | |
17 | this(Set.of(leftTilePosition, rightTilePosition)); | |
18 | } | |
19 | ||
20 | public EdgePosition(Set<PositionVector> positions) { | |
21 | this.positions.addAll(positions); | |
22 |
1
1. <init> : negated conditional → KILLED |
if (positions.size() != 2) { |
23 | throw new IllegalArgumentException("The irrigation channel position must be adjacent"); | |
24 | } | |
25 |
1
1. <init> : negated conditional → KILLED |
if (getLeftTilePosition().distance(getRightTilePosition()) != 1) { |
26 | throw new IllegalArgumentException("The irrigation channel position must be adjacent"); | |
27 | } | |
28 | } | |
29 | ||
30 | public PositionVector getLeftTilePosition() { | |
31 |
1
1. getLeftTilePosition : replaced return value with null for com/takenoko/layers/irrigation/EdgePosition::getLeftTilePosition → KILLED |
return positions.stream().findFirst().orElseThrow(); |
32 | } | |
33 | ||
34 | public PositionVector getRightTilePosition() { | |
35 |
1
1. getRightTilePosition : replaced return value with null for com/takenoko/layers/irrigation/EdgePosition::getRightTilePosition → KILLED |
return positions.stream().skip(1).findFirst().orElseThrow(); |
36 | } | |
37 | ||
38 | public EdgePosition copy() { | |
39 |
1
1. copy : replaced return value with null for com/takenoko/layers/irrigation/EdgePosition::copy → NO_COVERAGE |
return new EdgePosition(positions); |
40 | } | |
41 | ||
42 | /** | |
43 | * Return the list of all the neighbours of the irrigation channel position A neighbour is a | |
44 | * position that is connected to the irrigation channel position | |
45 | * | |
46 | * @return the list of all the neighbours of the irrigation channel position | |
47 | */ | |
48 | public List<EdgePosition> getNeighbours() { | |
49 | PositionVector leftTilePosition = getLeftTilePosition(); | |
50 | PositionVector rightTilePosition = getRightTilePosition(); | |
51 | HashSet<Vector> neighboursInCommon = new HashSet<>(leftTilePosition.getNeighbors()); | |
52 | neighboursInCommon.retainAll(rightTilePosition.getNeighbors()); | |
53 |
1
1. getNeighbours : replaced return value with Collections.emptyList for com/takenoko/layers/irrigation/EdgePosition::getNeighbours → KILLED |
return neighboursInCommon.stream() |
54 | .map( | |
55 | vector -> | |
56 |
1
1. lambda$getNeighbours$0 : replaced return value with Collections.emptyList for com/takenoko/layers/irrigation/EdgePosition::lambda$getNeighbours$0 → KILLED |
List.of( |
57 | new EdgePosition( | |
58 | leftTilePosition, vector.toPositionVector()), | |
59 | new EdgePosition( | |
60 | rightTilePosition, vector.toPositionVector()))) | |
61 | .flatMap(List::stream) | |
62 | .toList(); | |
63 | } | |
64 | ||
65 | public static List<EdgePosition> getEdgePositions(PositionVector positionVector) { | |
66 |
1
1. getEdgePositions : replaced return value with Collections.emptyList for com/takenoko/layers/irrigation/EdgePosition::getEdgePositions → KILLED |
return positionVector.getNeighbors().stream() |
67 |
1
1. lambda$getEdgePositions$1 : replaced return value with null for com/takenoko/layers/irrigation/EdgePosition::lambda$getEdgePositions$1 → KILLED |
.map(vector -> new EdgePosition(positionVector, vector.toPositionVector())) |
68 | .toList(); | |
69 | } | |
70 | ||
71 | @Override | |
72 | public boolean equals(Object o) { | |
73 |
2
1. equals : negated conditional → KILLED 2. equals : replaced boolean return with false for com/takenoko/layers/irrigation/EdgePosition::equals → KILLED |
if (this == o) return true; |
74 |
3
1. equals : replaced boolean return with true for com/takenoko/layers/irrigation/EdgePosition::equals → TIMED_OUT 2. equals : negated conditional → KILLED 3. equals : negated conditional → KILLED |
if (o == null || getClass() != o.getClass()) return false; |
75 | EdgePosition that = (EdgePosition) o; | |
76 |
2
1. equals : replaced boolean return with false for com/takenoko/layers/irrigation/EdgePosition::equals → KILLED 2. equals : replaced boolean return with true for com/takenoko/layers/irrigation/EdgePosition::equals → KILLED |
return Objects.equals(positions, that.positions); |
77 | } | |
78 | ||
79 | @Override | |
80 | public int hashCode() { | |
81 |
1
1. hashCode : replaced int return with 0 for com/takenoko/layers/irrigation/EdgePosition::hashCode → TIMED_OUT |
return Objects.hash(positions); |
82 | } | |
83 | ||
84 | @Override | |
85 | public String toString() { | |
86 |
1
1. toString : replaced return value with "" for com/takenoko/layers/irrigation/EdgePosition::toString → TIMED_OUT |
return "IrrigationChannelPosition{" + "positions=" + positions + '}'; |
87 | } | |
88 | } | |
Mutations | ||
22 |
1.1 |
|
25 |
1.1 |
|
31 |
1.1 |
|
35 |
1.1 |
|
39 |
1.1 |
|
53 |
1.1 |
|
56 |
1.1 |
|
66 |
1.1 |
|
67 |
1.1 |
|
73 |
1.1 2.2 |
|
74 |
1.1 2.2 3.3 |
|
76 |
1.1 2.2 |
|
81 |
1.1 |
|
86 |
1.1 |