Skip to content
Snippets Groups Projects

Resolve "Upgrade prettier for records"

Merged Colin DAMON requested to merge 109-upgrade-prettier-for-records into master
12 files
+ 484
2053
Compare changes
  • Side-by-side
  • Inline
Files
12
@@ -2,7 +2,7 @@ package fr.ippon.life;
import java.util.Set;
public record Cell(int row, int column) {
public record Cell(int row, int column) {
private static final int LOW_POPULATION_THRESHOLD = 2;
private static final int HIGH_POPULATION_THRESHOLD = 3;
private static final int BORN_THRESHOLD = HIGH_POPULATION_THRESHOLD;
@@ -10,8 +10,7 @@ public record Cell(int row, int column) {
boolean stayAlive(Set<Cell> aliveCells) {
long neighbourgCount = countNeigbours(aliveCells);
return neighbourgCount == LOW_POPULATION_THRESHOLD
|| neighbourgCount == HIGH_POPULATION_THRESHOLD;
return neighbourgCount == LOW_POPULATION_THRESHOLD || neighbourgCount == HIGH_POPULATION_THRESHOLD;
}
boolean born(Set<Cell> aliveCells) {
@@ -19,9 +18,7 @@ public record Cell(int row, int column) {
}
private long countNeigbours(Set<Cell> aliveCells) {
return aliveCells.stream()
.filter(this::isNeighbour)
.count();
return aliveCells.stream().filter(this::isNeighbour).count();
}
private boolean isNeighbour(Cell other) {
@@ -29,8 +26,7 @@ public record Cell(int row, int column) {
return false;
}
return delta(row, other.row) <= 1
&& delta(column, other.column) <= 1;
return delta(row, other.row) <= 1 && delta(column, other.column) <= 1;
}
private static int delta(int first, int second) {
Loading