diff options
Diffstat (limited to 'src/main/java/bjc/data/Pair.java')
| -rw-r--r-- | src/main/java/bjc/data/Pair.java | 41 |
1 files changed, 16 insertions, 25 deletions
diff --git a/src/main/java/bjc/data/Pair.java b/src/main/java/bjc/data/Pair.java index 610e89c..ea2f82f 100644 --- a/src/main/java/bjc/data/Pair.java +++ b/src/main/java/bjc/data/Pair.java @@ -22,7 +22,7 @@ public class Pair<LeftType, RightType> implements IPair<LeftType, RightType> { /** Create a new pair with both sides set to null. */ public Pair() { - + // Do nothing :) } /** @@ -42,8 +42,7 @@ public class Pair<LeftType, RightType> implements IPair<LeftType, RightType> { @Override public <BoundLeft, BoundRight> IPair<BoundLeft, BoundRight> bind( final BiFunction<LeftType, RightType, IPair<BoundLeft, BoundRight>> binder) { - if (binder == null) - throw new NullPointerException("Binder must not be null."); + if (binder == null) throw new NullPointerException("Binder must not be null."); return binder.apply(leftValue, rightValue); } @@ -51,8 +50,7 @@ public class Pair<LeftType, RightType> implements IPair<LeftType, RightType> { @Override public <BoundLeft> IPair<BoundLeft, RightType> bindLeft(final Function<LeftType, IPair<BoundLeft, RightType>> leftBinder) { - if (leftBinder == null) - throw new NullPointerException("Binder must not be null"); + if (leftBinder == null) throw new NullPointerException("Binder must not be null"); return leftBinder.apply(leftValue); } @@ -60,8 +58,7 @@ public class Pair<LeftType, RightType> implements IPair<LeftType, RightType> { @Override public <BoundRight> IPair<LeftType, BoundRight> bindRight( final Function<RightType, IPair<LeftType, BoundRight>> rightBinder) { - if (rightBinder == null) - throw new NullPointerException("Binder must not be null"); + if (rightBinder == null) throw new NullPointerException("Binder must not be null"); return rightBinder.apply(rightValue); } @@ -84,8 +81,7 @@ public class Pair<LeftType, RightType> implements IPair<LeftType, RightType> { @Override public <NewLeft> IPair<NewLeft, RightType> mapLeft(final Function<LeftType, NewLeft> mapper) { - if (mapper == null) - throw new NullPointerException("Mapper must not be null"); + if (mapper == null) throw new NullPointerException("Mapper must not be null"); return new Pair<>(mapper.apply(leftValue), rightValue); } @@ -93,8 +89,7 @@ public class Pair<LeftType, RightType> implements IPair<LeftType, RightType> { @Override public <NewRight> IPair<LeftType, NewRight> mapRight(final Function<RightType, NewRight> mapper) { - if (mapper == null) - throw new NullPointerException("Mapper must not be null"); + if (mapper == null) throw new NullPointerException("Mapper must not be null"); return new Pair<>(leftValue, mapper.apply(rightValue)); } @@ -102,8 +97,7 @@ public class Pair<LeftType, RightType> implements IPair<LeftType, RightType> { @Override public <MergedType> MergedType merge(final BiFunction<LeftType, RightType, MergedType> merger) { - if (merger == null) - throw new NullPointerException("Merger must not be null"); + if (merger == null) throw new NullPointerException("Merger must not be null"); return merger.apply(leftValue, rightValue); } @@ -137,26 +131,23 @@ public class Pair<LeftType, RightType> implements IPair<LeftType, RightType> { @Override public boolean equals(final Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (!(obj instanceof Pair<?, ?>)) - return false; + if (this == obj) return true; + if (obj == null) return false; + if (!(obj instanceof Pair<?, ?>)) return false; final Pair<?, ?> other = (Pair<?, ?>) obj; if (leftValue == null) { - if (other.leftValue != null) - return false; - } else if (!leftValue.equals(other.leftValue)) + if (other.leftValue != null) return false; + } else if (!leftValue.equals(other.leftValue)) { return false; + } if (rightValue == null) { - if (other.rightValue != null) - return false; - } else if (!rightValue.equals(other.rightValue)) + if (other.rightValue != null) return false; + } else if (!rightValue.equals(other.rightValue)) { return false; + } return true; } |
