From 98d55289fcbb460e9c24c91391a08476be01f424 Mon Sep 17 00:00:00 2001 From: cpovirk Date: Wed, 16 Oct 2024 10:15:00 -0700 Subject: [PATCH] Address https://errorprone.info/bugpattern/UnnecessaryDefaultInEnumSwitch warnings. RELNOTES=n/a PiperOrigin-RevId: 686551836 --- .../concurrent/AbstractFutureFootprintBenchmark.java | 2 -- .../com/google/common/collect/SortedListsTest.java | 5 +---- .../google/common/graph/GraphEquivalenceTest.java | 8 ++------ .../google/common/graph/NetworkEquivalenceTest.java | 8 ++------ .../common/util/concurrent/MoreExecutorsTest.java | 1 - .../guava/src/com/google/common/base/Stopwatch.java | 3 +-- android/guava/src/com/google/common/collect/Cut.java | 12 ++++-------- .../guava/src/com/google/common/collect/Range.java | 6 ++---- .../src/com/google/common/collect/TreeMultiset.java | 6 ++---- .../src/com/google/common/graph/ElementOrder.java | 3 +-- .../src/com/google/common/math/BigIntegerMath.java | 10 +++------- .../guava/src/com/google/common/math/DoubleMath.java | 4 +--- .../guava/src/com/google/common/math/IntMath.java | 10 +++------- .../concurrent/AbstractFutureFootprintBenchmark.java | 2 -- .../com/google/common/collect/SortedListsTest.java | 5 +---- .../google/common/graph/GraphEquivalenceTest.java | 8 ++------ .../google/common/graph/NetworkEquivalenceTest.java | 8 ++------ .../common/util/concurrent/MoreExecutorsTest.java | 1 - guava/src/com/google/common/base/Stopwatch.java | 3 +-- guava/src/com/google/common/collect/Cut.java | 12 ++++-------- guava/src/com/google/common/collect/Range.java | 6 ++---- .../src/com/google/common/collect/TreeMultiset.java | 6 ++---- guava/src/com/google/common/graph/ElementOrder.java | 3 +-- guava/src/com/google/common/math/BigIntegerMath.java | 10 +++------- guava/src/com/google/common/math/DoubleMath.java | 4 +--- guava/src/com/google/common/math/IntMath.java | 10 +++------- 26 files changed, 44 insertions(+), 112 deletions(-) diff --git a/android/guava-tests/benchmark/com/google/common/util/concurrent/AbstractFutureFootprintBenchmark.java b/android/guava-tests/benchmark/com/google/common/util/concurrent/AbstractFutureFootprintBenchmark.java index 9a2d87140dff..09edd1dcb013 100644 --- a/android/guava-tests/benchmark/com/google/common/util/concurrent/AbstractFutureFootprintBenchmark.java +++ b/android/guava-tests/benchmark/com/google/common/util/concurrent/AbstractFutureFootprintBenchmark.java @@ -98,8 +98,6 @@ public void run() { case FAILED: f.setException(new Exception()); break; - default: - throw new AssertionError(); } return f; } diff --git a/android/guava-tests/test/com/google/common/collect/SortedListsTest.java b/android/guava-tests/test/com/google/common/collect/SortedListsTest.java index 7109c6c0ff2c..95d2e16933e4 100644 --- a/android/guava-tests/test/com/google/common/collect/SortedListsTest.java +++ b/android/guava-tests/test/com/google/common/collect/SortedListsTest.java @@ -73,8 +73,6 @@ void assertModelAgrees( return; } break; - default: - throw new AssertionError(); } // key is not present int nextHigherIndex = list.size(); @@ -91,9 +89,8 @@ void assertModelAgrees( case INVERTED_INSERTION_INDEX: assertEquals(-1 - nextHigherIndex, answer); return; - default: - throw new AssertionError(); } + throw new AssertionError(); } public void testWithoutDups() { diff --git a/android/guava-tests/test/com/google/common/graph/GraphEquivalenceTest.java b/android/guava-tests/test/com/google/common/graph/GraphEquivalenceTest.java index 38e3903aaa87..87247d5b56ec 100644 --- a/android/guava-tests/test/com/google/common/graph/GraphEquivalenceTest.java +++ b/android/guava-tests/test/com/google/common/graph/GraphEquivalenceTest.java @@ -56,9 +56,8 @@ private static MutableGraph createGraph(EdgeType edgeType) { return GraphBuilder.undirected().allowsSelfLoops(true).build(); case DIRECTED: return GraphBuilder.directed().allowsSelfLoops(true).build(); - default: - throw new IllegalStateException("Unexpected edge type: " + edgeType); } + throw new IllegalStateException("Unexpected edge type: " + edgeType); } private static EdgeType oppositeType(EdgeType edgeType) { @@ -67,9 +66,8 @@ private static EdgeType oppositeType(EdgeType edgeType) { return EdgeType.DIRECTED; case DIRECTED: return EdgeType.UNDIRECTED; - default: - throw new IllegalStateException("Unexpected edge type: " + edgeType); } + throw new IllegalStateException("Unexpected edge type: " + edgeType); } @Test @@ -150,8 +148,6 @@ public void equivalent_edgeDirectionsDiffer() { case DIRECTED: assertThat(graph).isNotEqualTo(g2); break; - default: - throw new IllegalStateException("Unexpected edge type: " + edgeType); } } } diff --git a/android/guava-tests/test/com/google/common/graph/NetworkEquivalenceTest.java b/android/guava-tests/test/com/google/common/graph/NetworkEquivalenceTest.java index 4aab1271b5f9..69d18fa1b039 100644 --- a/android/guava-tests/test/com/google/common/graph/NetworkEquivalenceTest.java +++ b/android/guava-tests/test/com/google/common/graph/NetworkEquivalenceTest.java @@ -61,9 +61,8 @@ private static MutableNetwork createNetwork(EdgeType edgeType) return NetworkBuilder.undirected().allowsSelfLoops(true).build(); case DIRECTED: return NetworkBuilder.directed().allowsSelfLoops(true).build(); - default: - throw new IllegalStateException("Unexpected edge type: " + edgeType); } + throw new IllegalStateException("Unexpected edge type: " + edgeType); } private static EdgeType oppositeType(EdgeType edgeType) { @@ -72,9 +71,8 @@ private static EdgeType oppositeType(EdgeType edgeType) { return EdgeType.DIRECTED; case DIRECTED: return EdgeType.UNDIRECTED; - default: - throw new IllegalStateException("Unexpected edge type: " + edgeType); } + throw new IllegalStateException("Unexpected edge type: " + edgeType); } @Test @@ -184,8 +182,6 @@ public void equivalent_edgeDirectionsDiffer() { case DIRECTED: assertThat(network).isNotEqualTo(g2); break; - default: - throw new IllegalStateException("Unexpected edge type: " + edgeType); } } } diff --git a/android/guava-tests/test/com/google/common/util/concurrent/MoreExecutorsTest.java b/android/guava-tests/test/com/google/common/util/concurrent/MoreExecutorsTest.java index ae72e417618a..a5acf28afe77 100644 --- a/android/guava-tests/test/com/google/common/util/concurrent/MoreExecutorsTest.java +++ b/android/guava-tests/test/com/google/common/util/concurrent/MoreExecutorsTest.java @@ -285,7 +285,6 @@ void awaitTimedWaiting(Thread thread) { case TIMED_WAITING: return; case TERMINATED: - default: throw new AssertionError(); } } diff --git a/android/guava/src/com/google/common/base/Stopwatch.java b/android/guava/src/com/google/common/base/Stopwatch.java index e68d666d5aef..ba1a0f29a4f2 100644 --- a/android/guava/src/com/google/common/base/Stopwatch.java +++ b/android/guava/src/com/google/common/base/Stopwatch.java @@ -260,8 +260,7 @@ private static String abbreviate(TimeUnit unit) { return "h"; case DAYS: return "d"; - default: - throw new AssertionError(); } + throw new AssertionError(); } } diff --git a/android/guava/src/com/google/common/collect/Cut.java b/android/guava/src/com/google/common/collect/Cut.java index 7de1a44f7e36..b64e054abfae 100644 --- a/android/guava/src/com/google/common/collect/Cut.java +++ b/android/guava/src/com/google/common/collect/Cut.java @@ -339,9 +339,8 @@ Cut withLowerBoundType(BoundType boundType, DiscreteDomain domain) { case OPEN: C previous = domain.previous(endpoint); return (previous == null) ? Cut.belowAll() : new AboveValue(previous); - default: - throw new AssertionError(); } + throw new AssertionError(); } @Override @@ -352,9 +351,8 @@ Cut withUpperBoundType(BoundType boundType, DiscreteDomain domain) { return (previous == null) ? Cut.aboveAll() : new AboveValue(previous); case OPEN: return this; - default: - throw new AssertionError(); } + throw new AssertionError(); } @Override @@ -423,9 +421,8 @@ Cut withLowerBoundType(BoundType boundType, DiscreteDomain domain) { case CLOSED: C next = domain.next(endpoint); return (next == null) ? Cut.belowAll() : belowValue(next); - default: - throw new AssertionError(); } + throw new AssertionError(); } @Override @@ -436,9 +433,8 @@ Cut withUpperBoundType(BoundType boundType, DiscreteDomain domain) { return (next == null) ? Cut.aboveAll() : belowValue(next); case CLOSED: return this; - default: - throw new AssertionError(); } + throw new AssertionError(); } @Override diff --git a/android/guava/src/com/google/common/collect/Range.java b/android/guava/src/com/google/common/collect/Range.java index 2475a80e920a..baf6bf55be40 100644 --- a/android/guava/src/com/google/common/collect/Range.java +++ b/android/guava/src/com/google/common/collect/Range.java @@ -231,9 +231,8 @@ public static > Range upTo(C endpoint, BoundType boun return lessThan(endpoint); case CLOSED: return atMost(endpoint); - default: - throw new AssertionError(); } + throw new AssertionError(); } /** @@ -266,9 +265,8 @@ public static > Range downTo(C endpoint, BoundType bo return greaterThan(endpoint); case CLOSED: return atLeast(endpoint); - default: - throw new AssertionError(); } + throw new AssertionError(); } private static final Range ALL = new Range<>(Cut.belowAll(), Cut.aboveAll()); diff --git a/android/guava/src/com/google/common/collect/TreeMultiset.java b/android/guava/src/com/google/common/collect/TreeMultiset.java index 94e4b9d1ad0a..85e7e9932e92 100644 --- a/android/guava/src/com/google/common/collect/TreeMultiset.java +++ b/android/guava/src/com/google/common/collect/TreeMultiset.java @@ -190,9 +190,8 @@ private long aggregateBelowRange(Aggregate aggr, @CheckForNull AvlNode node) return aggr.nodeAggregate(node) + aggr.treeAggregate(node.left); case CLOSED: return aggr.treeAggregate(node.left); - default: - throw new AssertionError(); } + throw new AssertionError(); } else { return aggr.treeAggregate(node.left) + aggr.nodeAggregate(node) @@ -216,9 +215,8 @@ private long aggregateAboveRange(Aggregate aggr, @CheckForNull AvlNode node) return aggr.nodeAggregate(node) + aggr.treeAggregate(node.right); case CLOSED: return aggr.treeAggregate(node.right); - default: - throw new AssertionError(); } + throw new AssertionError(); } else { return aggr.treeAggregate(node.right) + aggr.nodeAggregate(node) diff --git a/android/guava/src/com/google/common/graph/ElementOrder.java b/android/guava/src/com/google/common/graph/ElementOrder.java index b5985a280b86..fc2abbb59f9a 100644 --- a/android/guava/src/com/google/common/graph/ElementOrder.java +++ b/android/guava/src/com/google/common/graph/ElementOrder.java @@ -197,9 +197,8 @@ Map createMap(int expectedSize) { return Maps.newLinkedHashMapWithExpectedSize(expectedSize); case SORTED: return Maps.newTreeMap(comparator()); - default: - throw new AssertionError(); } + throw new AssertionError(); } @SuppressWarnings("unchecked") diff --git a/android/guava/src/com/google/common/math/BigIntegerMath.java b/android/guava/src/com/google/common/math/BigIntegerMath.java index 5f7ce6b57577..ada0f0f57c80 100644 --- a/android/guava/src/com/google/common/math/BigIntegerMath.java +++ b/android/guava/src/com/google/common/math/BigIntegerMath.java @@ -117,10 +117,8 @@ public static int log2(BigInteger x, RoundingMode mode) { BigInteger x2 = x.pow(2); int logX2Floor = x2.bitLength() - 1; return (logX2Floor < 2 * logFloor + 1) ? logFloor : logFloor + 1; - - default: - throw new AssertionError(); } + throw new AssertionError(); } /* @@ -204,9 +202,8 @@ public static int log10(BigInteger x, RoundingMode mode) { BigInteger x2 = x.pow(2); BigInteger halfPowerSquared = floorPow.pow(2).multiply(BigInteger.TEN); return (x2.compareTo(halfPowerSquared) <= 0) ? floorLog : floorLog + 1; - default: - throw new AssertionError(); } + throw new AssertionError(); } private static final double LN_10 = Math.log(10); @@ -250,9 +247,8 @@ public static BigInteger sqrt(BigInteger x, RoundingMode mode) { * halfSquare. */ return (halfSquare.compareTo(x) >= 0) ? sqrtFloor : sqrtFloor.add(BigInteger.ONE); - default: - throw new AssertionError(); } + throw new AssertionError(); } @GwtIncompatible // TODO diff --git a/android/guava/src/com/google/common/math/DoubleMath.java b/android/guava/src/com/google/common/math/DoubleMath.java index be0d8cfc9e0d..531334cf4d5a 100644 --- a/android/guava/src/com/google/common/math/DoubleMath.java +++ b/android/guava/src/com/google/common/math/DoubleMath.java @@ -107,10 +107,8 @@ static double roundIntermediate(double x, RoundingMode mode) { return z; } } - - default: - throw new AssertionError(); } + throw new AssertionError(); } /** diff --git a/android/guava/src/com/google/common/math/IntMath.java b/android/guava/src/com/google/common/math/IntMath.java index 7ab7765cf840..74b6de68a681 100644 --- a/android/guava/src/com/google/common/math/IntMath.java +++ b/android/guava/src/com/google/common/math/IntMath.java @@ -136,10 +136,8 @@ public static int log2(int x, RoundingMode mode) { // floor(2^(logFloor + 0.5)) int logFloor = (Integer.SIZE - 1) - leadingZeros; return logFloor + lessThanBranchFree(cmp, x); - - default: - throw new AssertionError(); } + throw new AssertionError(); } /** The biggest half power of two that can fit in an unsigned int. */ @@ -173,9 +171,8 @@ public static int log10(int x, RoundingMode mode) { case HALF_EVEN: // sqrt(10) is irrational, so log10(x) - logFloor is never exactly 0.5 return logFloor + lessThanBranchFree(halfPowersOf10[logFloor], x); - default: - throw new AssertionError(); } + throw new AssertionError(); } private static int log10Floor(int x) { @@ -292,9 +289,8 @@ public static int sqrt(int x, RoundingMode mode) { * signed int, so lessThanBranchFree is safe for use. */ return sqrtFloor + lessThanBranchFree(halfSquare, x); - default: - throw new AssertionError(); } + throw new AssertionError(); } private static int sqrtFloor(int x) { diff --git a/guava-tests/benchmark/com/google/common/util/concurrent/AbstractFutureFootprintBenchmark.java b/guava-tests/benchmark/com/google/common/util/concurrent/AbstractFutureFootprintBenchmark.java index 9a2d87140dff..09edd1dcb013 100644 --- a/guava-tests/benchmark/com/google/common/util/concurrent/AbstractFutureFootprintBenchmark.java +++ b/guava-tests/benchmark/com/google/common/util/concurrent/AbstractFutureFootprintBenchmark.java @@ -98,8 +98,6 @@ public void run() { case FAILED: f.setException(new Exception()); break; - default: - throw new AssertionError(); } return f; } diff --git a/guava-tests/test/com/google/common/collect/SortedListsTest.java b/guava-tests/test/com/google/common/collect/SortedListsTest.java index 7109c6c0ff2c..95d2e16933e4 100644 --- a/guava-tests/test/com/google/common/collect/SortedListsTest.java +++ b/guava-tests/test/com/google/common/collect/SortedListsTest.java @@ -73,8 +73,6 @@ void assertModelAgrees( return; } break; - default: - throw new AssertionError(); } // key is not present int nextHigherIndex = list.size(); @@ -91,9 +89,8 @@ void assertModelAgrees( case INVERTED_INSERTION_INDEX: assertEquals(-1 - nextHigherIndex, answer); return; - default: - throw new AssertionError(); } + throw new AssertionError(); } public void testWithoutDups() { diff --git a/guava-tests/test/com/google/common/graph/GraphEquivalenceTest.java b/guava-tests/test/com/google/common/graph/GraphEquivalenceTest.java index 38e3903aaa87..87247d5b56ec 100644 --- a/guava-tests/test/com/google/common/graph/GraphEquivalenceTest.java +++ b/guava-tests/test/com/google/common/graph/GraphEquivalenceTest.java @@ -56,9 +56,8 @@ private static MutableGraph createGraph(EdgeType edgeType) { return GraphBuilder.undirected().allowsSelfLoops(true).build(); case DIRECTED: return GraphBuilder.directed().allowsSelfLoops(true).build(); - default: - throw new IllegalStateException("Unexpected edge type: " + edgeType); } + throw new IllegalStateException("Unexpected edge type: " + edgeType); } private static EdgeType oppositeType(EdgeType edgeType) { @@ -67,9 +66,8 @@ private static EdgeType oppositeType(EdgeType edgeType) { return EdgeType.DIRECTED; case DIRECTED: return EdgeType.UNDIRECTED; - default: - throw new IllegalStateException("Unexpected edge type: " + edgeType); } + throw new IllegalStateException("Unexpected edge type: " + edgeType); } @Test @@ -150,8 +148,6 @@ public void equivalent_edgeDirectionsDiffer() { case DIRECTED: assertThat(graph).isNotEqualTo(g2); break; - default: - throw new IllegalStateException("Unexpected edge type: " + edgeType); } } } diff --git a/guava-tests/test/com/google/common/graph/NetworkEquivalenceTest.java b/guava-tests/test/com/google/common/graph/NetworkEquivalenceTest.java index 4aab1271b5f9..69d18fa1b039 100644 --- a/guava-tests/test/com/google/common/graph/NetworkEquivalenceTest.java +++ b/guava-tests/test/com/google/common/graph/NetworkEquivalenceTest.java @@ -61,9 +61,8 @@ private static MutableNetwork createNetwork(EdgeType edgeType) return NetworkBuilder.undirected().allowsSelfLoops(true).build(); case DIRECTED: return NetworkBuilder.directed().allowsSelfLoops(true).build(); - default: - throw new IllegalStateException("Unexpected edge type: " + edgeType); } + throw new IllegalStateException("Unexpected edge type: " + edgeType); } private static EdgeType oppositeType(EdgeType edgeType) { @@ -72,9 +71,8 @@ private static EdgeType oppositeType(EdgeType edgeType) { return EdgeType.DIRECTED; case DIRECTED: return EdgeType.UNDIRECTED; - default: - throw new IllegalStateException("Unexpected edge type: " + edgeType); } + throw new IllegalStateException("Unexpected edge type: " + edgeType); } @Test @@ -184,8 +182,6 @@ public void equivalent_edgeDirectionsDiffer() { case DIRECTED: assertThat(network).isNotEqualTo(g2); break; - default: - throw new IllegalStateException("Unexpected edge type: " + edgeType); } } } diff --git a/guava-tests/test/com/google/common/util/concurrent/MoreExecutorsTest.java b/guava-tests/test/com/google/common/util/concurrent/MoreExecutorsTest.java index ae72e417618a..a5acf28afe77 100644 --- a/guava-tests/test/com/google/common/util/concurrent/MoreExecutorsTest.java +++ b/guava-tests/test/com/google/common/util/concurrent/MoreExecutorsTest.java @@ -285,7 +285,6 @@ void awaitTimedWaiting(Thread thread) { case TIMED_WAITING: return; case TERMINATED: - default: throw new AssertionError(); } } diff --git a/guava/src/com/google/common/base/Stopwatch.java b/guava/src/com/google/common/base/Stopwatch.java index d67b22cd87bb..3b2421bf9889 100644 --- a/guava/src/com/google/common/base/Stopwatch.java +++ b/guava/src/com/google/common/base/Stopwatch.java @@ -281,8 +281,7 @@ private static String abbreviate(TimeUnit unit) { return "h"; case DAYS: return "d"; - default: - throw new AssertionError(); } + throw new AssertionError(); } } diff --git a/guava/src/com/google/common/collect/Cut.java b/guava/src/com/google/common/collect/Cut.java index 7de1a44f7e36..b64e054abfae 100644 --- a/guava/src/com/google/common/collect/Cut.java +++ b/guava/src/com/google/common/collect/Cut.java @@ -339,9 +339,8 @@ Cut withLowerBoundType(BoundType boundType, DiscreteDomain domain) { case OPEN: C previous = domain.previous(endpoint); return (previous == null) ? Cut.belowAll() : new AboveValue(previous); - default: - throw new AssertionError(); } + throw new AssertionError(); } @Override @@ -352,9 +351,8 @@ Cut withUpperBoundType(BoundType boundType, DiscreteDomain domain) { return (previous == null) ? Cut.aboveAll() : new AboveValue(previous); case OPEN: return this; - default: - throw new AssertionError(); } + throw new AssertionError(); } @Override @@ -423,9 +421,8 @@ Cut withLowerBoundType(BoundType boundType, DiscreteDomain domain) { case CLOSED: C next = domain.next(endpoint); return (next == null) ? Cut.belowAll() : belowValue(next); - default: - throw new AssertionError(); } + throw new AssertionError(); } @Override @@ -436,9 +433,8 @@ Cut withUpperBoundType(BoundType boundType, DiscreteDomain domain) { return (next == null) ? Cut.aboveAll() : belowValue(next); case CLOSED: return this; - default: - throw new AssertionError(); } + throw new AssertionError(); } @Override diff --git a/guava/src/com/google/common/collect/Range.java b/guava/src/com/google/common/collect/Range.java index 2475a80e920a..baf6bf55be40 100644 --- a/guava/src/com/google/common/collect/Range.java +++ b/guava/src/com/google/common/collect/Range.java @@ -231,9 +231,8 @@ public static > Range upTo(C endpoint, BoundType boun return lessThan(endpoint); case CLOSED: return atMost(endpoint); - default: - throw new AssertionError(); } + throw new AssertionError(); } /** @@ -266,9 +265,8 @@ public static > Range downTo(C endpoint, BoundType bo return greaterThan(endpoint); case CLOSED: return atLeast(endpoint); - default: - throw new AssertionError(); } + throw new AssertionError(); } private static final Range ALL = new Range<>(Cut.belowAll(), Cut.aboveAll()); diff --git a/guava/src/com/google/common/collect/TreeMultiset.java b/guava/src/com/google/common/collect/TreeMultiset.java index e918cd6cfe95..cfe28441fa82 100644 --- a/guava/src/com/google/common/collect/TreeMultiset.java +++ b/guava/src/com/google/common/collect/TreeMultiset.java @@ -192,9 +192,8 @@ private long aggregateBelowRange(Aggregate aggr, @CheckForNull AvlNode node) return aggr.nodeAggregate(node) + aggr.treeAggregate(node.left); case CLOSED: return aggr.treeAggregate(node.left); - default: - throw new AssertionError(); } + throw new AssertionError(); } else { return aggr.treeAggregate(node.left) + aggr.nodeAggregate(node) @@ -218,9 +217,8 @@ private long aggregateAboveRange(Aggregate aggr, @CheckForNull AvlNode node) return aggr.nodeAggregate(node) + aggr.treeAggregate(node.right); case CLOSED: return aggr.treeAggregate(node.right); - default: - throw new AssertionError(); } + throw new AssertionError(); } else { return aggr.treeAggregate(node.right) + aggr.nodeAggregate(node) diff --git a/guava/src/com/google/common/graph/ElementOrder.java b/guava/src/com/google/common/graph/ElementOrder.java index b5985a280b86..fc2abbb59f9a 100644 --- a/guava/src/com/google/common/graph/ElementOrder.java +++ b/guava/src/com/google/common/graph/ElementOrder.java @@ -197,9 +197,8 @@ Map createMap(int expectedSize) { return Maps.newLinkedHashMapWithExpectedSize(expectedSize); case SORTED: return Maps.newTreeMap(comparator()); - default: - throw new AssertionError(); } + throw new AssertionError(); } @SuppressWarnings("unchecked") diff --git a/guava/src/com/google/common/math/BigIntegerMath.java b/guava/src/com/google/common/math/BigIntegerMath.java index 5f7ce6b57577..ada0f0f57c80 100644 --- a/guava/src/com/google/common/math/BigIntegerMath.java +++ b/guava/src/com/google/common/math/BigIntegerMath.java @@ -117,10 +117,8 @@ public static int log2(BigInteger x, RoundingMode mode) { BigInteger x2 = x.pow(2); int logX2Floor = x2.bitLength() - 1; return (logX2Floor < 2 * logFloor + 1) ? logFloor : logFloor + 1; - - default: - throw new AssertionError(); } + throw new AssertionError(); } /* @@ -204,9 +202,8 @@ public static int log10(BigInteger x, RoundingMode mode) { BigInteger x2 = x.pow(2); BigInteger halfPowerSquared = floorPow.pow(2).multiply(BigInteger.TEN); return (x2.compareTo(halfPowerSquared) <= 0) ? floorLog : floorLog + 1; - default: - throw new AssertionError(); } + throw new AssertionError(); } private static final double LN_10 = Math.log(10); @@ -250,9 +247,8 @@ public static BigInteger sqrt(BigInteger x, RoundingMode mode) { * halfSquare. */ return (halfSquare.compareTo(x) >= 0) ? sqrtFloor : sqrtFloor.add(BigInteger.ONE); - default: - throw new AssertionError(); } + throw new AssertionError(); } @GwtIncompatible // TODO diff --git a/guava/src/com/google/common/math/DoubleMath.java b/guava/src/com/google/common/math/DoubleMath.java index be0d8cfc9e0d..531334cf4d5a 100644 --- a/guava/src/com/google/common/math/DoubleMath.java +++ b/guava/src/com/google/common/math/DoubleMath.java @@ -107,10 +107,8 @@ static double roundIntermediate(double x, RoundingMode mode) { return z; } } - - default: - throw new AssertionError(); } + throw new AssertionError(); } /** diff --git a/guava/src/com/google/common/math/IntMath.java b/guava/src/com/google/common/math/IntMath.java index 7ab7765cf840..74b6de68a681 100644 --- a/guava/src/com/google/common/math/IntMath.java +++ b/guava/src/com/google/common/math/IntMath.java @@ -136,10 +136,8 @@ public static int log2(int x, RoundingMode mode) { // floor(2^(logFloor + 0.5)) int logFloor = (Integer.SIZE - 1) - leadingZeros; return logFloor + lessThanBranchFree(cmp, x); - - default: - throw new AssertionError(); } + throw new AssertionError(); } /** The biggest half power of two that can fit in an unsigned int. */ @@ -173,9 +171,8 @@ public static int log10(int x, RoundingMode mode) { case HALF_EVEN: // sqrt(10) is irrational, so log10(x) - logFloor is never exactly 0.5 return logFloor + lessThanBranchFree(halfPowersOf10[logFloor], x); - default: - throw new AssertionError(); } + throw new AssertionError(); } private static int log10Floor(int x) { @@ -292,9 +289,8 @@ public static int sqrt(int x, RoundingMode mode) { * signed int, so lessThanBranchFree is safe for use. */ return sqrtFloor + lessThanBranchFree(halfSquare, x); - default: - throw new AssertionError(); } + throw new AssertionError(); } private static int sqrtFloor(int x) {