diff options
author | pacien | 2018-01-11 21:45:05 +0100 |
---|---|---|
committer | pacien | 2018-01-11 21:45:05 +0100 |
commit | 6760ddb7a47b96dae5b1b626417dcf3cbd4055b1 (patch) | |
tree | 0e919dc3c36d186e544221055cb9284aed93d8bc /src/main/java | |
parent | 7fc6fc06bf5b1e6c3a07640cfb2ac7456e030e06 (diff) | |
download | wallj-6760ddb7a47b96dae5b1b626417dcf3cbd4055b1.tar.gz |
Implement board equals and hashCode
Signed-off-by: pacien <pacien.trangirard@pacien.net>
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/fr/umlv/java/wallj/board/Board.java | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/main/java/fr/umlv/java/wallj/board/Board.java b/src/main/java/fr/umlv/java/wallj/board/Board.java index c846fd3..015a4c0 100644 --- a/src/main/java/fr/umlv/java/wallj/board/Board.java +++ b/src/main/java/fr/umlv/java/wallj/board/Board.java | |||
@@ -3,6 +3,8 @@ package fr.umlv.java.wallj.board; | |||
3 | import fr.umlv.java.wallj.model.BlockType; | 3 | import fr.umlv.java.wallj.model.BlockType; |
4 | import fr.umlv.java.wallj.utils.Matrix; | 4 | import fr.umlv.java.wallj.utils.Matrix; |
5 | 5 | ||
6 | import java.util.Arrays; | ||
7 | |||
6 | /** | 8 | /** |
7 | * An immutable BlockType matrix. | 9 | * An immutable BlockType matrix. |
8 | * | 10 | * |
@@ -65,4 +67,17 @@ public final class Board { | |||
65 | return TileVec2.of(Matrix.getWidth(map), Matrix.getHeight(map)); | 67 | return TileVec2.of(Matrix.getWidth(map), Matrix.getHeight(map)); |
66 | } | 68 | } |
67 | 69 | ||
70 | @Override | ||
71 | public boolean equals(Object o) { | ||
72 | if (this == o) return true; | ||
73 | if (!(o instanceof Board)) return false; | ||
74 | Board board = (Board) o; | ||
75 | return Arrays.deepEquals(map, board.map); | ||
76 | } | ||
77 | |||
78 | @Override | ||
79 | public int hashCode() { | ||
80 | return Arrays.hashCode(map); | ||
81 | } | ||
82 | |||
68 | } | 83 | } |