Skip to content

Commit 12a3308

Browse files
committed
add docu + small fixes
1 parent 3d2fc34 commit 12a3308

File tree

7 files changed

+18
-14
lines changed

7 files changed

+18
-14
lines changed

src/main/java/bwem/Asserter.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,16 @@ void throwIllegalStateException(String message) {
1818
try {
1919
throw exception;
2020
} catch (IllegalStateException e) {
21-
try {
22-
outStream.write(Arrays
23-
.stream(e.getStackTrace())
24-
.map(s -> s.toString() + "\n")
25-
.collect(Collectors.joining())
26-
.getBytes());
27-
} catch (IOException ex) {
28-
ex.printStackTrace();
21+
if (outStream != null) {
22+
try {
23+
outStream.write(Arrays
24+
.stream(e.getStackTrace())
25+
.map(s -> s.toString() + "\n")
26+
.collect(Collectors.joining())
27+
.getBytes());
28+
} catch (IOException ex) {
29+
ex.printStackTrace();
30+
}
2931
}
3032
}
3133
}

src/main/java/bwem/BWEM.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
* By default BWEM throws when an invalid state is encountered.
2424
* But if you know what you are doing, you can skip these throws by setting
2525
* {@link #setFailOnError} to `false`.
26+
* These errors will then be outputted to {@link System.err}, but this can also be changed
27+
* with {@link #setFailOutputStream} (if you set it to `null` the errors will be completely ignored).
2628
*/
2729
public final class BWEM {
2830
private final BWMap map;

src/main/java/bwem/BWMap.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public abstract class BWMap {
3737
Altitude highestAltitude;
3838
final Asserter asserter;
3939

40-
BWMap(final Game game, Asserter asserter) {
40+
BWMap(final Game game, final Asserter asserter) {
4141
this.game = game;
4242
this.players = game.getPlayers();
4343
this.mineralPatches = game.getMinerals();

src/main/java/bwem/MiniTile.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ public final class MiniTile {
4242
areaId; // 0 -> unwalkable ; > 0 -> index of some Area ; < 0 -> some walkable terrain, but
4343
// too small to be part of an Area
4444

45-
private Asserter asserter;
45+
private final Asserter asserter;
4646

47-
MiniTile(Asserter asserter) {
47+
MiniTile(final Asserter asserter) {
4848
this.altitude = Altitude.UNINITIALIZED;
4949
this.areaId = UNINITIALIZED;
5050
this.asserter = asserter;

src/main/java/bwem/TempAreaInfo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class TempAreaInfo {
3333

3434
private final Asserter asserter;
3535

36-
TempAreaInfo(Asserter asserter) {
36+
TempAreaInfo(final Asserter asserter) {
3737
this.isValid = false;
3838
this.id = AreaId.ZERO;
3939
this.walkPositionWithHighestAltitude = new WalkPosition(0, 0);

src/main/java/bwem/Tile.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public final class Tile {
4141
private boolean isBuildable;
4242
private boolean isDoodad;
4343

44-
private Asserter asserter;
44+
private final Asserter asserter;
4545

4646
Tile(final Asserter asserter) {
4747
this.markable = new Markable(Tile.staticMarkable);

src/main/java/bwem/TileData.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ final class TileData {
1919

2020
final Asserter asserter;
2121

22-
TileData(final int tileCount, final int miniTileCount, Asserter asserter) {
22+
TileData(final int tileCount, final int miniTileCount, final Asserter asserter) {
2323
tiles = new Tile[tileCount];
2424
this.asserter = asserter;
2525
for (int i = 0; i < tileCount; ++i) {

0 commit comments

Comments
 (0)