Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ public void testEntrySetRetainAll() {
Set<Entry<K, V>> entriesToRetain =
singleton(mapEntry(originalEntry.getKey(), originalEntry.getValue()));
if (supportsRemove) {
boolean shouldRemove = (entrySet.size() > entriesToRetain.size());
boolean shouldRemove = entrySet.size() > entriesToRetain.size();
boolean didRemove = entrySet.retainAll(entriesToRetain);
assertEquals(shouldRemove, didRemove);
assertEquals(entriesToRetain.size(), map.size());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ private TestSuite createReserializedSuite(SortedMultisetTestSuiteBuilder<E> pare
new ForwardingTestMultisetGenerator<E>(delegate) {
@Override
public SortedMultiset<E> create(Object... entries) {
return SerializableTester.reserialize(((SortedMultiset<E>) super.create(entries)));
return SerializableTester.reserialize((SortedMultiset<E>) super.create(entries));
}
})
.named(parentBuilder.getName() + " reserialized")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class SetHashCodeTester<E> extends AbstractSetTester<E> {
public void testHashCode() {
int expectedHashCode = 0;
for (E element : getSampleElements()) {
expectedHashCode += ((element == null) ? 0 : element.hashCode());
expectedHashCode += (element == null) ? 0 : element.hashCode();
}
assertEquals(
"A Set's hashCode() should be the sum of those of its elements.",
Expand All @@ -55,7 +55,7 @@ public void testHashCode_containingNull() {
Collection<E> elements = getSampleElements(getNumElements() - 1);
int expectedHashCode = 0;
for (E element : elements) {
expectedHashCode += ((element == null) ? 0 : element.hashCode());
expectedHashCode += (element == null) ? 0 : element.hashCode();
}

elements.add(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ long manual(int reps) {
for (int i = 0; i < reps; i++) {
long start = System.nanoTime();
// here is where you would do something
total += (System.nanoTime() - start);
total += System.nanoTime() - start;
}
return total;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ boolean doEquals(byte[] a, byte[] b) {
}
boolean areEqual = true;
for (int i = 0; i < a.length; i++) {
areEqual &= (a[i] == b[i]);
areEqual &= a[i] == b[i];
}
return areEqual;
}
Expand All @@ -85,7 +85,7 @@ boolean doEquals(byte[] a, byte[] b) {
for (int i = 0; i < a.length; i++) {
result = (byte) (result | a[i] ^ b[i]);
}
return (result == 0);
return result == 0;
}
},
XORING_TO_INT {
Expand All @@ -98,7 +98,7 @@ boolean doEquals(byte[] a, byte[] b) {
for (int i = 0; i < a.length; i++) {
result |= a[i] ^ b[i];
}
return (result == 0);
return result == 0;
}
},
MESSAGE_DIGEST_IS_EQUAL {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class MonitorBenchmark {
@SuppressWarnings("unchecked")
void setUp() throws Exception {
String prefix =
(useMonitor ? "com.google.common.util.concurrent.MonitorBased" : "java.util.concurrent.");
useMonitor ? "com.google.common.util.concurrent.MonitorBased" : "java.util.concurrent.";
String className = prefix + queueType + "BlockingQueue";
Constructor<?> constructor = Class.forName(className).getConstructor(int.class);
queue = (BlockingQueue<String>) constructor.newInstance(capacity);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1941,7 +1941,7 @@ public String load(String key) throws InterruptedException {
// doConcurrentGet alternates between calling getUnchecked and calling get, but an unchecked
// exception thrown by the loader is always wrapped as an UncheckedExecutionException.
assertThat(result.get(i)).isInstanceOf(UncheckedExecutionException.class);
assertThat(((UncheckedExecutionException) result.get(i))).hasCauseThat().isSameInstanceAs(e);
assertThat((UncheckedExecutionException) result.get(i)).hasCauseThat().isSameInstanceAs(e);
}

// subsequent calls should call the loader again, not get the old exception
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ static <K, V> LocalCache<K, V> toLocalCache(Cache<K, V> cache) {
* without throwing an exception.
*/
static boolean hasLocalCache(Cache<?, ?> cache) {
return (checkNotNull(cache) instanceof LocalLoadingCache);
return checkNotNull(cache) instanceof LocalLoadingCache;
}

static void drainRecencyQueues(Cache<?, ?> cache) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3055,7 +3055,7 @@ public int hashCode() {

@Override
public boolean equals(@Nullable Object o) {
return (o instanceof SerializableCacheLoader);
return o instanceof SerializableCacheLoader;
}
}

Expand All @@ -3071,7 +3071,7 @@ public int hashCode() {

@Override
public boolean equals(@Nullable Object o) {
return (o instanceof SerializableRemovalListener);
return o instanceof SerializableRemovalListener;
}
}

Expand All @@ -3088,7 +3088,7 @@ public int hashCode() {

@Override
public boolean equals(@Nullable Object o) {
return (o instanceof SerializableTicker);
return o instanceof SerializableTicker;
}
}

Expand All @@ -3105,7 +3105,7 @@ public int hashCode() {

@Override
public boolean equals(@Nullable Object o) {
return (o instanceof SerializableWeigher);
return o instanceof SerializableWeigher;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,15 @@ public int[] call() throws Exception {
{
int newValue = random.nextInt(3);
int oldValue = multiset.setCount(key, newValue);
deltas[keyIndex] += (newValue - oldValue);
deltas[keyIndex] += newValue - oldValue;
break;
}
case SET_COUNT_IF:
{
int newValue = random.nextInt(3);
int oldValue = multiset.count(key);
if (multiset.setCount(key, oldValue, newValue)) {
deltas[keyIndex] += (newValue - oldValue);
deltas[keyIndex] += newValue - oldValue;
}
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ public void funnel(Long value, PrimitiveSink into) {

@Override
public boolean equals(@Nullable Object object) {
return (object instanceof CustomFunnel);
return object instanceof CustomFunnel;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public void testCrc32cByteTable() {
int crc = i;
for (int j = 7; j >= 0; j--) {
int mask = -(crc & 1);
crc = ((crc >>> 1) ^ (CRC32C_GENERATOR_FLIPPED & mask));
crc = (crc >>> 1) ^ (CRC32C_GENERATOR_FLIPPED & mask);
}
expected[i] = crc;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ static void checkNoFunnels(HashFunction function) {
// test whether the hash values have same output bits
same |= ~(hash1 ^ hash2);
// test whether the hash values have different output bits
diff |= (hash1 ^ hash2);
diff |= hash1 ^ hash2;

count++;
// check whether we've exceeded the probabilistically
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ public void testSqrtExactMatchesFloorOrThrows() {
for (int x : POSITIVE_INTEGER_CANDIDATES) {
int floor = IntMath.sqrt(x, FLOOR);
// We only expect an exception if x was not a perfect square.
boolean isPerfectSquare = (floor * floor == x);
boolean isPerfectSquare = floor * floor == x;
try {
assertEquals(floor, IntMath.sqrt(x, UNNECESSARY));
assertTrue(isPerfectSquare);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ public void testSqrtExactMatchesFloorOrThrows() {
for (long x : POSITIVE_LONG_CANDIDATES) {
long sqrtFloor = LongMath.sqrt(x, FLOOR);
// We only expect an exception if x was not a perfect square.
boolean isPerfectSquare = (sqrtFloor * sqrtFloor == x);
boolean isPerfectSquare = sqrtFloor * sqrtFloor == x;
try {
assertEquals(sqrtFloor, LongMath.sqrt(x, UNNECESSARY));
assertTrue(isPerfectSquare);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ private static void checkFromStringCase(
assertNotNull(expectHost);

// Apply withDefaultPort(), yielding hp2.
boolean badDefaultPort = (defaultPort < 0 || defaultPort > 65535);
boolean badDefaultPort = defaultPort < 0 || defaultPort > 65535;
HostAndPort hp2 = null;
try {
hp2 = hp.withDefaultPort(defaultPort);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ private static void addTests(
suite.addTest(new GeneratedMonitorTest(method, scenario, fair, timeout, expectedOutcome));
}
} else {
Timeout implicitTimeout = (isTryEnter(method) ? Timeout.ZERO : Timeout.MAX);
Timeout implicitTimeout = isTryEnter(method) ? Timeout.ZERO : Timeout.MAX;
if (timeoutsToUse.timeouts.contains(implicitTimeout)) {
suite.addTest(new GeneratedMonitorTest(method, scenario, fair, null, expectedOutcome));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ void sleepMillis(int millis) {

void sleepMicros(String caption, long micros) {
instant += MICROSECONDS.toNanos(micros);
events.add(caption + String.format(Locale.ROOT, "%3.2f", (micros / 1000000.0)));
events.add(caption + String.format(Locale.ROOT, "%3.2f", micros / 1000000.0));
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion android/guava/src/com/google/common/base/Utf8.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public static int encodedLength(CharSequence sequence) {
for (; i < utf16Length; i++) {
char c = sequence.charAt(i);
if (c < 0x800) {
utf8Length += ((0x7f - c) >>> 31); // branch free!
utf8Length += (0x7f - c) >>> 31; // branch free!
} else {
utf8Length += encodedLengthGeneral(sequence, i);
break;
Expand Down
6 changes: 3 additions & 3 deletions android/guava/src/com/google/common/cache/LocalCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -1679,9 +1679,9 @@ static int rehash(int h) {
// using variant of single-word Wang/Jenkins hash.
// TODO(kevinb): use Hashing/move this to Hashing?
h += (h << 15) ^ 0xffffcd7d;
h ^= (h >>> 10);
h += (h << 3);
h ^= (h >>> 6);
h ^= h >>> 10;
h += h << 3;
h ^= h >>> 6;
h += (h << 2) + (h << 14);
return h ^ (h >>> 16);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ public boolean addAll(Collection<? extends V> collection) {
boolean changed = delegate.addAll(collection);
if (changed) {
int newSize = delegate.size();
totalSize += (newSize - oldSize);
totalSize += newSize - oldSize;
if (oldSize == 0) {
addToMap();
}
Expand Down Expand Up @@ -566,7 +566,7 @@ public boolean removeAll(Collection<?> c) {
boolean changed = delegate.removeAll(c);
if (changed) {
int newSize = delegate.size();
totalSize += (newSize - oldSize);
totalSize += newSize - oldSize;
removeIfEmpty();
}
return changed;
Expand All @@ -579,7 +579,7 @@ public boolean retainAll(Collection<?> c) {
boolean changed = delegate.retainAll(c);
if (changed) {
int newSize = delegate.size();
totalSize += (newSize - oldSize);
totalSize += newSize - oldSize;
removeIfEmpty();
}
return changed;
Expand Down Expand Up @@ -613,7 +613,7 @@ public boolean removeAll(Collection<?> c) {
boolean changed = Sets.removeAllImpl((Set<V>) delegate, c);
if (changed) {
int newSize = delegate.size();
totalSize += (newSize - oldSize);
totalSize += newSize - oldSize;
removeIfEmpty();
}
return changed;
Expand Down Expand Up @@ -776,7 +776,7 @@ public boolean addAll(int index, Collection<? extends V> c) {
boolean changed = getListDelegate().addAll(index, c);
if (changed) {
int newSize = getDelegate().size();
totalSize += (newSize - oldSize);
totalSize += newSize - oldSize;
if (oldSize == 0) {
addToMap();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ private CompactHashing() {}
private static final int HASH_TABLE_BITS_MAX_BITS = 5;

/** Use high bits of metadata for modification count. */
static final int MODIFICATION_COUNT_INCREMENT = (1 << HASH_TABLE_BITS_MAX_BITS);
static final int MODIFICATION_COUNT_INCREMENT = 1 << HASH_TABLE_BITS_MAX_BITS;

/** Bitmask that selects the low bits of metadata to get hashTableBits. */
static final int HASH_TABLE_BITS_MASK = (1 << HASH_TABLE_BITS_MAX_BITS) - 1;
Expand Down
10 changes: 5 additions & 5 deletions android/guava/src/com/google/common/collect/Cut.java
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ Cut<C> withLowerBoundType(BoundType boundType, DiscreteDomain<C> domain) {
return this;
case OPEN:
C previous = domain.previous(endpoint);
return (previous == null) ? Cut.<C>belowAll() : new AboveValue<C>(previous);
return (previous == null) ? Cut.belowAll() : new AboveValue<>(previous);
}
throw new AssertionError();
}
Expand All @@ -347,7 +347,7 @@ Cut<C> withUpperBoundType(BoundType boundType, DiscreteDomain<C> domain) {
switch (boundType) {
case CLOSED:
C previous = domain.previous(endpoint);
return (previous == null) ? Cut.<C>aboveAll() : new AboveValue<C>(previous);
return (previous == null) ? Cut.aboveAll() : new AboveValue<>(previous);
case OPEN:
return this;
}
Expand Down Expand Up @@ -418,7 +418,7 @@ Cut<C> withLowerBoundType(BoundType boundType, DiscreteDomain<C> domain) {
return this;
case CLOSED:
C next = domain.next(endpoint);
return (next == null) ? Cut.<C>belowAll() : belowValue(next);
return (next == null) ? Cut.belowAll() : belowValue(next);
}
throw new AssertionError();
}
Expand All @@ -428,7 +428,7 @@ Cut<C> withUpperBoundType(BoundType boundType, DiscreteDomain<C> domain) {
switch (boundType) {
case OPEN:
C next = domain.next(endpoint);
return (next == null) ? Cut.<C>aboveAll() : belowValue(next);
return (next == null) ? Cut.aboveAll() : belowValue(next);
case CLOSED:
return this;
}
Expand Down Expand Up @@ -458,7 +458,7 @@ C greatestValueBelow(DiscreteDomain<C> domain) {
@Override
Cut<C> canonical(DiscreteDomain<C> domain) {
C next = leastValueAbove(domain);
return (next != null) ? belowValue(next) : Cut.<C>aboveAll();
return (next != null) ? belowValue(next) : Cut.aboveAll();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import static com.google.common.base.Predicates.not;
import static com.google.common.collect.CollectPreconditions.checkNonnegative;
import static com.google.common.collect.Maps.immutableEntry;
import static java.util.Collections.emptyList;
import static java.util.Collections.emptySet;
import static java.util.Collections.unmodifiableList;
import static java.util.Collections.unmodifiableSet;

Expand All @@ -31,7 +33,6 @@
import com.google.j2objc.annotations.WeakOuter;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
Expand Down Expand Up @@ -111,9 +112,7 @@ public Collection<V> removeAll(@Nullable Object key) {
@SuppressWarnings("EmptyList") // ImmutableList doesn't support nullable element types
Collection<V> unmodifiableEmptyCollection() {
// These return false, rather than throwing a UOE, on remove calls.
return (unfiltered instanceof SetMultimap)
? Collections.<V>emptySet()
: Collections.<V>emptyList();
return (unfiltered instanceof SetMultimap) ? emptySet() : emptyList();
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion android/guava/src/com/google/common/collect/HashBiMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -947,7 +947,7 @@ public V setValue(@ParametricNullness V value) {
@Override
public BiMap<V, K> inverse() {
BiMap<V, K> result = inverse;
return (result == null) ? inverse = new Inverse<K, V>(this) : result;
return (result == null) ? inverse = new Inverse<>(this) : result;
}

private static final class Inverse<K extends @Nullable Object, V extends @Nullable Object>
Expand Down
Loading
Loading