From ecd219fb2d381358d32d0821570e19365ed0bab4 Mon Sep 17 00:00:00 2001 From: Tobias Ottenweller Date: Wed, 19 Jun 2013 13:42:16 +0200 Subject: [PATCH] Added parameter checks and final attributes to the FloodUtil class. --- src/de/craftinc/gates/util/FloodUtil.java | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/de/craftinc/gates/util/FloodUtil.java b/src/de/craftinc/gates/util/FloodUtil.java index 3d4967a..f8c36d5 100644 --- a/src/de/craftinc/gates/util/FloodUtil.java +++ b/src/de/craftinc/gates/util/FloodUtil.java @@ -52,7 +52,7 @@ public class FloodUtil * @param blocks All blocks inside the gate. * @return A Set containing all frame block. Will never return 'null'. */ - public static Set getFrame(Set blocks) + public static Set getFrame(final Set blocks) { if (blocks == null || blocks.isEmpty()) { return new HashSet(); @@ -101,7 +101,7 @@ public class FloodUtil - protected static Set _getFrame(Set blocks, Set searchDirections) + protected static Set _getFrame(final Set blocks, final Set searchDirections) { Set frameBlocks = new HashSet(); @@ -125,8 +125,12 @@ public class FloodUtil * @param locations All locations inside the gate. * @return A Set containing all frame block. Will never return 'null'. */ - public static Set getFrameWithLocations(Set locations) + public static Set getFrameWithLocations(final Set locations) { + if (locations == null) { + throw new IllegalArgumentException("'locations' must not be 'null'"); + } + Set blocks = new HashSet(); for (Location l : locations) { @@ -138,9 +142,13 @@ public class FloodUtil // For the same frame and location this set of blocks is deterministic - public static Set getGatePortalBlocks(Block block) + public static Set getGatePortalBlocks(final Block block) { - int frameBlockSearchLimit = Plugin.getPlugin().getConfig().getInt(Plugin.confMaxGateBlocksKey); + if (block == null) { + throw new IllegalArgumentException("'block' must not be 'null'"); + } + + int frameBlockSearchLimit = Plugin.getPlugin().getConfig().getInt(Plugin.confMaxGateBlocksKey); Set blocks1 = getAirFloodBlocks(block, new HashSet(), exp1, frameBlockSearchLimit); Set blocks2 = getAirFloodBlocks(block, new HashSet(), exp2, frameBlockSearchLimit); @@ -165,7 +173,10 @@ public class FloodUtil } - protected static Set getAirFloodBlocks(Block startBlock, Set foundBlocks, Set expandFaces, int limit) + protected static Set getAirFloodBlocks(final Block startBlock, + Set foundBlocks, + final Set expandFaces, + int limit) { if (foundBlocks == null) { return null;