The following issues were found
guava/src/com/google/common/collect/Tables.java
27 issues
Line: 17
* limitations under the License.
*/
package com.google.common.collect;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.collect.NullnessCasts.uncheckedCastNullableTToT;
Reported by PMD.
Line: 55
*/
@GwtCompatible
@ElementTypesAreNonnullByDefault
public final class Tables {
private Tables() {}
/**
* Returns a {@link Collector} that accumulates elements into a {@code Table} created using the
* specified supplier, whose cells are generated by applying the provided mapping functions to the
Reported by PMD.
Line: 182
}
if (obj instanceof Cell) {
Cell<?, ?, ?> other = (Cell<?, ?, ?>) obj;
return Objects.equal(getRowKey(), other.getRowKey())
&& Objects.equal(getColumnKey(), other.getColumnKey())
&& Objects.equal(getValue(), other.getValue());
}
return false;
}
Reported by PMD.
Line: 183
if (obj instanceof Cell) {
Cell<?, ?, ?> other = (Cell<?, ?, ?>) obj;
return Objects.equal(getRowKey(), other.getRowKey())
&& Objects.equal(getColumnKey(), other.getColumnKey())
&& Objects.equal(getValue(), other.getValue());
}
return false;
}
Reported by PMD.
Line: 184
Cell<?, ?, ?> other = (Cell<?, ?, ?>) obj;
return Objects.equal(getRowKey(), other.getRowKey())
&& Objects.equal(getColumnKey(), other.getColumnKey())
&& Objects.equal(getValue(), other.getValue());
}
return false;
}
@Override
Reported by PMD.
Line: 221
private static class TransposeTable<
C extends @Nullable Object, R extends @Nullable Object, V extends @Nullable Object>
extends AbstractTable<C, R, V> {
final Table<R, C, V> original;
TransposeTable(Table<R, C, V> original) {
this.original = checkNotNull(original);
}
Reported by PMD.
Line: 222
private static class TransposeTable<
C extends @Nullable Object, R extends @Nullable Object, V extends @Nullable Object>
extends AbstractTable<C, R, V> {
final Table<R, C, V> original;
TransposeTable(Table<R, C, V> original) {
this.original = checkNotNull(original);
}
Reported by PMD.
Line: 328
}
};
@SuppressWarnings("unchecked")
@Override
Iterator<Cell<C, R, V>> cellIterator() {
return Iterators.transform(original.cellSet().iterator(), (Function) TRANSPOSE_CELL);
}
Reported by PMD.
Line: 331
@SuppressWarnings("unchecked")
@Override
Iterator<Cell<C, R, V>> cellIterator() {
return Iterators.transform(original.cellSet().iterator(), (Function) TRANSPOSE_CELL);
}
@SuppressWarnings("unchecked")
@Override
Spliterator<Cell<C, R, V>> cellSpliterator() {
Reported by PMD.
Line: 337
@SuppressWarnings("unchecked")
@Override
Spliterator<Cell<C, R, V>> cellSpliterator() {
return CollectSpliterators.map(original.cellSet().spliterator(), (Function) TRANSPOSE_CELL);
}
}
/**
* Creates a table that uses the specified backing map and factory. It can generate a table based
Reported by PMD.
guava/src/com/google/common/collect/RegularImmutableSortedSet.java
27 issues
Line: 106
}
@Override
public boolean containsAll(Collection<?> targets) {
// TODO(jlevy): For optimal performance, use a binary search when
// targets.size() < size() / log(size())
// TODO(kevinb): see if we can share code with OrderedIterator after it
// graduates from labs.
if (targets instanceof Multiset) {
Reported by PMD.
Line: 43
@GwtCompatible(serializable = true, emulated = true)
@SuppressWarnings({"serial", "rawtypes"})
@ElementTypesAreNonnullByDefault
final class RegularImmutableSortedSet<E> extends ImmutableSortedSet<E> {
static final RegularImmutableSortedSet<Comparable> NATURAL_EMPTY_SET =
new RegularImmutableSortedSet<>(ImmutableList.<Comparable>of(), Ordering.natural());
private final transient ImmutableList<E> elements;
Reported by PMD.
Line: 43
@GwtCompatible(serializable = true, emulated = true)
@SuppressWarnings({"serial", "rawtypes"})
@ElementTypesAreNonnullByDefault
final class RegularImmutableSortedSet<E> extends ImmutableSortedSet<E> {
static final RegularImmutableSortedSet<Comparable> NATURAL_EMPTY_SET =
new RegularImmutableSortedSet<>(ImmutableList.<Comparable>of(), Ordering.natural());
private final transient ImmutableList<E> elements;
Reported by PMD.
Line: 43
@GwtCompatible(serializable = true, emulated = true)
@SuppressWarnings({"serial", "rawtypes"})
@ElementTypesAreNonnullByDefault
final class RegularImmutableSortedSet<E> extends ImmutableSortedSet<E> {
static final RegularImmutableSortedSet<Comparable> NATURAL_EMPTY_SET =
new RegularImmutableSortedSet<>(ImmutableList.<Comparable>of(), Ordering.natural());
private final transient ImmutableList<E> elements;
Reported by PMD.
Line: 78
@GwtIncompatible // NavigableSet
@Override
public UnmodifiableIterator<E> descendingIterator() {
return elements.reverse().iterator();
}
@Override
public Spliterator<E> spliterator() {
return asList().spliterator();
Reported by PMD.
Line: 83
@Override
public Spliterator<E> spliterator() {
return asList().spliterator();
}
@Override
public void forEach(Consumer<? super E> action) {
elements.forEach(action);
Reported by PMD.
Line: 106
}
@Override
public boolean containsAll(Collection<?> targets) {
// TODO(jlevy): For optimal performance, use a binary search when
// targets.size() < size() / log(size())
// TODO(kevinb): see if we can share code with OrderedIterator after it
// graduates from labs.
if (targets instanceof Multiset) {
Reported by PMD.
Line: 106
}
@Override
public boolean containsAll(Collection<?> targets) {
// TODO(jlevy): For optimal performance, use a binary search when
// targets.size() < size() / log(size())
// TODO(kevinb): see if we can share code with OrderedIterator after it
// graduates from labs.
if (targets instanceof Multiset) {
Reported by PMD.
Line: 106
}
@Override
public boolean containsAll(Collection<?> targets) {
// TODO(jlevy): For optimal performance, use a binary search when
// targets.size() < size() / log(size())
// TODO(kevinb): see if we can share code with OrderedIterator after it
// graduates from labs.
if (targets instanceof Multiset) {
Reported by PMD.
Line: 114
if (targets instanceof Multiset) {
targets = ((Multiset<?>) targets).elementSet();
}
if (!SortedIterables.hasSameComparator(comparator(), targets) || (targets.size() <= 1)) {
return super.containsAll(targets);
}
/*
* If targets is a sorted set with the same comparator, containsAll can run
Reported by PMD.
guava/src/com/google/common/collect/RegularImmutableBiMap.java
27 issues
Line: 132
*/
@CanIgnoreReturnValue
private static int checkNoConflictInValueBucket(
Object value, Entry<?, ?> entry, @CheckForNull ImmutableMapEntry<?, ?> valueBucketHead) {
int bucketSize = 0;
for (; valueBucketHead != null; valueBucketHead = valueBucketHead.getNextInValueBucket()) {
checkNoConflict(!value.equals(valueBucketHead.getValue()), "value", entry, valueBucketHead);
bucketSize++;
}
Reported by PMD.
Line: 57
@CheckForNull private final transient @Nullable ImmutableMapEntry<K, V>[] valueTable;
@VisibleForTesting final transient Entry<K, V>[] entries;
private final transient int mask;
private final transient int hashCode;
static <K, V> ImmutableBiMap<K, V> fromEntries(Entry<K, V>... entries) {
return fromEntryArray(entries.length, entries);
}
Reported by PMD.
Line: 82
for (int i = 0; i < n; i++) {
// requireNonNull is safe because the first `n` elements have been filled in.
Entry<K, V> entry = requireNonNull(entryArray[i]);
K key = entry.getKey();
V value = entry.getValue();
checkEntryNotNull(key, value);
int keyHash = key.hashCode();
int valueHash = value.hashCode();
int keyBucket = Hashing.smear(keyHash) & mask;
Reported by PMD.
Line: 83
// requireNonNull is safe because the first `n` elements have been filled in.
Entry<K, V> entry = requireNonNull(entryArray[i]);
K key = entry.getKey();
V value = entry.getValue();
checkEntryNotNull(key, value);
int keyHash = key.hashCode();
int valueHash = value.hashCode();
int keyBucket = Hashing.smear(keyHash) & mask;
int valueBucket = Hashing.smear(valueHash) & mask;
Reported by PMD.
Line: 85
K key = entry.getKey();
V value = entry.getValue();
checkEntryNotNull(key, value);
int keyHash = key.hashCode();
int valueHash = value.hashCode();
int keyBucket = Hashing.smear(keyHash) & mask;
int valueBucket = Hashing.smear(valueHash) & mask;
ImmutableMapEntry<K, V> nextInKeyBucket = keyTable[keyBucket];
Reported by PMD.
Line: 86
V value = entry.getValue();
checkEntryNotNull(key, value);
int keyHash = key.hashCode();
int valueHash = value.hashCode();
int keyBucket = Hashing.smear(keyHash) & mask;
int valueBucket = Hashing.smear(valueHash) & mask;
ImmutableMapEntry<K, V> nextInKeyBucket = keyTable[keyBucket];
int keyBucketLength = checkNoConflictInKeyBucket(key, entry, nextInKeyBucket);
Reported by PMD.
Line: 101
ImmutableMapEntry<K, V> newEntry =
(nextInValueBucket == null && nextInKeyBucket == null)
? RegularImmutableMap.makeImmutable(entry, key, value)
: new NonTerminalImmutableBiMapEntry<>(
key, value, nextInKeyBucket, nextInValueBucket);
keyTable[keyBucket] = newEntry;
valueTable[valueBucket] = newEntry;
entries[i] = newEntry;
hashCode += keyHash ^ valueHash;
Reported by PMD.
Line: 187
return entries.length;
}
@LazyInit @RetainedWith @CheckForNull private transient ImmutableBiMap<V, K> inverse;
@Override
public ImmutableBiMap<V, K> inverse() {
if (isEmpty()) {
return ImmutableBiMap.of();
Reported by PMD.
Line: 202
@Override
public int size() {
return inverse().size();
}
@Override
public ImmutableBiMap<K, V> inverse() {
return RegularImmutableBiMap.this;
Reported by PMD.
Line: 213
@Override
public void forEach(BiConsumer<? super V, ? super K> action) {
checkNotNull(action);
RegularImmutableBiMap.this.forEach((k, v) -> action.accept(v, k));
}
@Override
@CheckForNull
public K get(@CheckForNull Object value) {
Reported by PMD.
guava/src/com/google/common/collect/Ordering.java
27 issues
Line: 149
*/
@GwtCompatible
@ElementTypesAreNonnullByDefault
public abstract class Ordering<T extends @Nullable Object> implements Comparator<T> {
// Natural order
/**
* Returns a serializable ordering that uses the natural order of the values. The ordering throws
* a {@link NullPointerException} when passed a null parameter.
Reported by PMD.
Line: 149
*/
@GwtCompatible
@ElementTypesAreNonnullByDefault
public abstract class Ordering<T extends @Nullable Object> implements Comparator<T> {
// Natural order
/**
* Returns a serializable ordering that uses the natural order of the values. The ordering throws
* a {@link NullPointerException} when passed a null parameter.
Reported by PMD.
Line: 162
* <p><b>Java 8 users:</b> use {@link Comparator#naturalOrder} instead.
*/
@GwtCompatible(serializable = true)
@SuppressWarnings("unchecked") // TODO(kevinb): right way to explain this??
public static <C extends Comparable> Ordering<C> natural() {
return (Ordering<C>) NaturalOrdering.INSTANCE;
}
// Static factories
Reported by PMD.
Line: 327
@VisibleForTesting
static class ArbitraryOrdering extends Ordering<@Nullable Object> {
private final AtomicInteger counter = new AtomicInteger(0);
private final ConcurrentMap<Object, Integer> uids =
Platform.tryWeakKeys(new MapMaker()).makeMap();
private Integer getUid(Object obj) {
Integer uid = uids.get(obj);
Reported by PMD.
Line: 328
static class ArbitraryOrdering extends Ordering<@Nullable Object> {
private final AtomicInteger counter = new AtomicInteger(0);
private final ConcurrentMap<Object, Integer> uids =
Platform.tryWeakKeys(new MapMaker()).makeMap();
private Integer getUid(Object obj) {
Integer uid = uids.get(obj);
if (uid == null) {
Reported by PMD.
Line: 348
@Override
public int compare(@CheckForNull Object left, @CheckForNull Object right) {
if (left == right) {
return 0;
} else if (left == null) {
return -1;
} else if (right == null) {
return 1;
Reported by PMD.
Line: 362
}
// identityHashCode collision (rare, but not as rare as you'd think)
int result = getUid(left).compareTo(getUid(right));
if (result == 0) {
throw new AssertionError(); // extremely, extremely unlikely.
}
return result;
}
Reported by PMD.
Line: 738
public <E extends T> List<E> leastOf(Iterable<E> iterable, int k) {
if (iterable instanceof Collection) {
Collection<E> collection = (Collection<E>) iterable;
if (collection.size() <= 2L * k) {
// In this case, just dumping the collection to an array and sorting is
// faster than using the implementation for Iterator, which is
// specialized for k much smaller than n.
@SuppressWarnings("unchecked") // c only contains E's and doesn't escape
Reported by PMD.
Line: 744
// specialized for k much smaller than n.
@SuppressWarnings("unchecked") // c only contains E's and doesn't escape
E[] array = (E[]) collection.toArray();
Arrays.sort(array, this);
if (array.length > k) {
array = Arrays.copyOf(array, k);
}
return Collections.unmodifiableList(Arrays.asList(array));
Reported by PMD.
Line: 744
// specialized for k much smaller than n.
@SuppressWarnings("unchecked") // c only contains E's and doesn't escape
E[] array = (E[]) collection.toArray();
Arrays.sort(array, this);
if (array.length > k) {
array = Arrays.copyOf(array, k);
}
return Collections.unmodifiableList(Arrays.asList(array));
Reported by PMD.
guava/src/com/google/common/math/PairedStats.java
26 issues
Line: 43
@Beta
@GwtIncompatible
@ElementTypesAreNonnullByDefault
public final class PairedStats implements Serializable {
private final Stats xStats;
private final Stats yStats;
private final double sumOfProductsOfDeltas;
Reported by PMD.
Line: 45
@ElementTypesAreNonnullByDefault
public final class PairedStats implements Serializable {
private final Stats xStats;
private final Stats yStats;
private final double sumOfProductsOfDeltas;
/**
* Internal constructor. Users should use {@link PairedStatsAccumulator#snapshot}.
Reported by PMD.
Line: 45
@ElementTypesAreNonnullByDefault
public final class PairedStats implements Serializable {
private final Stats xStats;
private final Stats yStats;
private final double sumOfProductsOfDeltas;
/**
* Internal constructor. Users should use {@link PairedStatsAccumulator#snapshot}.
Reported by PMD.
Line: 46
public final class PairedStats implements Serializable {
private final Stats xStats;
private final Stats yStats;
private final double sumOfProductsOfDeltas;
/**
* Internal constructor. Users should use {@link PairedStatsAccumulator#snapshot}.
*
Reported by PMD.
Line: 46
public final class PairedStats implements Serializable {
private final Stats xStats;
private final Stats yStats;
private final double sumOfProductsOfDeltas;
/**
* Internal constructor. Users should use {@link PairedStatsAccumulator#snapshot}.
*
Reported by PMD.
Line: 47
private final Stats xStats;
private final Stats yStats;
private final double sumOfProductsOfDeltas;
/**
* Internal constructor. Users should use {@link PairedStatsAccumulator#snapshot}.
*
* <p>To ensure that the created instance obeys its contract, the parameters should satisfy the
Reported by PMD.
Line: 47
private final Stats xStats;
private final Stats yStats;
private final double sumOfProductsOfDeltas;
/**
* Internal constructor. Users should use {@link PairedStatsAccumulator#snapshot}.
*
* <p>To ensure that the created instance obeys its contract, the parameters should satisfy the
Reported by PMD.
Line: 140
if (isNaN(sumOfProductsOfDeltas)) {
return NaN;
}
double xSumOfSquaresOfDeltas = xStats().sumOfSquaresOfDeltas();
double ySumOfSquaresOfDeltas = yStats().sumOfSquaresOfDeltas();
checkState(xSumOfSquaresOfDeltas > 0.0);
checkState(ySumOfSquaresOfDeltas > 0.0);
// The product of two positive numbers can be zero if the multiplication underflowed. We
// force a positive value by effectively rounding up to MIN_VALUE.
Reported by PMD.
Line: 141
return NaN;
}
double xSumOfSquaresOfDeltas = xStats().sumOfSquaresOfDeltas();
double ySumOfSquaresOfDeltas = yStats().sumOfSquaresOfDeltas();
checkState(xSumOfSquaresOfDeltas > 0.0);
checkState(ySumOfSquaresOfDeltas > 0.0);
// The product of two positive numbers can be zero if the multiplication underflowed. We
// force a positive value by effectively rounding up to MIN_VALUE.
double productOfSumsOfSquaresOfDeltas =
Reported by PMD.
Line: 188
return LinearTransformation.forNaN();
}
double xSumOfSquaresOfDeltas = xStats.sumOfSquaresOfDeltas();
if (xSumOfSquaresOfDeltas > 0.0) {
if (yStats.sumOfSquaresOfDeltas() > 0.0) {
return LinearTransformation.mapping(xStats.mean(), yStats.mean())
.withSlope(sumOfProductsOfDeltas / xSumOfSquaresOfDeltas);
} else {
return LinearTransformation.horizontal(yStats.mean());
Reported by PMD.
guava-tests/test/com/google/common/util/concurrent/AbstractFutureFallbackAtomicHelperTest.java
26 issues
Line: 47
* test methods in these degenerate classloaders.
*/
public class AbstractFutureFallbackAtomicHelperTest extends TestCase {
// stash these in static fields to avoid loading them over and over again (speeds up test
// execution significantly)
/**
Reported by PMD.
Line: 74
// corresponding method on AbstractFutureTest in the correct classloader.
TestSuite suite = new TestSuite(AbstractFutureFallbackAtomicHelperTest.class.getName());
for (Method method : AbstractFutureTest.class.getDeclaredMethods()) {
if (Modifier.isPublic(method.getModifiers()) && method.getName().startsWith("test")) {
suite.addTest(
TestSuite.createTest(AbstractFutureFallbackAtomicHelperTest.class, method.getName()));
}
}
return suite;
Reported by PMD.
Line: 85
@Override
public void runTest() throws Exception {
// First ensure that our classloaders are initializing the correct helper versions
checkHelperVersion(getClass().getClassLoader(), "UnsafeAtomicHelper");
checkHelperVersion(NO_UNSAFE, "SafeAtomicHelper");
checkHelperVersion(NO_ATOMIC_REFERENCE_FIELD_UPDATER, "SynchronizedHelper");
// Run the corresponding AbstractFutureTest test method in a new classloader that disallows
// certain core jdk classes.
Reported by PMD.
Line: 85
@Override
public void runTest() throws Exception {
// First ensure that our classloaders are initializing the correct helper versions
checkHelperVersion(getClass().getClassLoader(), "UnsafeAtomicHelper");
checkHelperVersion(NO_UNSAFE, "SafeAtomicHelper");
checkHelperVersion(NO_ATOMIC_REFERENCE_FIELD_UPDATER, "SynchronizedHelper");
// Run the corresponding AbstractFutureTest test method in a new classloader that disallows
// certain core jdk classes.
Reported by PMD.
Line: 91
// Run the corresponding AbstractFutureTest test method in a new classloader that disallows
// certain core jdk classes.
ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(NO_UNSAFE);
try {
runTestMethod(NO_UNSAFE);
} finally {
Thread.currentThread().setContextClassLoader(oldClassLoader);
Reported by PMD.
Line: 92
// Run the corresponding AbstractFutureTest test method in a new classloader that disallows
// certain core jdk classes.
ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(NO_UNSAFE);
try {
runTestMethod(NO_UNSAFE);
} finally {
Thread.currentThread().setContextClassLoader(oldClassLoader);
}
Reported by PMD.
Line: 96
try {
runTestMethod(NO_UNSAFE);
} finally {
Thread.currentThread().setContextClassLoader(oldClassLoader);
}
Thread.currentThread().setContextClassLoader(NO_ATOMIC_REFERENCE_FIELD_UPDATER);
try {
runTestMethod(NO_ATOMIC_REFERENCE_FIELD_UPDATER);
Reported by PMD.
Line: 99
Thread.currentThread().setContextClassLoader(oldClassLoader);
}
Thread.currentThread().setContextClassLoader(NO_ATOMIC_REFERENCE_FIELD_UPDATER);
try {
runTestMethod(NO_ATOMIC_REFERENCE_FIELD_UPDATER);
// TODO(lukes): assert that the logs are full of errors
} finally {
Thread.currentThread().setContextClassLoader(oldClassLoader);
Reported by PMD.
Line: 104
runTestMethod(NO_ATOMIC_REFERENCE_FIELD_UPDATER);
// TODO(lukes): assert that the logs are full of errors
} finally {
Thread.currentThread().setContextClassLoader(oldClassLoader);
}
}
private void runTestMethod(ClassLoader classLoader) throws Exception {
Class<?> test = classLoader.loadClass(AbstractFutureTest.class.getName());
Reported by PMD.
Line: 108
}
}
private void runTestMethod(ClassLoader classLoader) throws Exception {
Class<?> test = classLoader.loadClass(AbstractFutureTest.class.getName());
test.getMethod(getName()).invoke(test.getDeclaredConstructor().newInstance());
}
private void checkHelperVersion(ClassLoader classLoader, String expectedHelperClassName)
Reported by PMD.
guava/src/com/google/common/collect/MultimapBuilder.java
26 issues
Line: 138
* safely cast to a {@link java.util.SortedSet}, and the {@link Multimap#asMap()} can safely be
* cast to a {@link java.util.SortedMap}.
*/
@SuppressWarnings("rawtypes")
public static MultimapBuilderWithKeys<Comparable> treeKeys() {
return treeKeys(Ordering.natural());
}
/**
Reported by PMD.
Line: 186
};
}
private static final class ArrayListSupplier<V extends @Nullable Object>
implements Supplier<List<V>>, Serializable {
private final int expectedValuesPerKey;
ArrayListSupplier(int expectedValuesPerKey) {
this.expectedValuesPerKey = checkNonnegative(expectedValuesPerKey, "expectedValuesPerKey");
Reported by PMD.
Line: 188
private static final class ArrayListSupplier<V extends @Nullable Object>
implements Supplier<List<V>>, Serializable {
private final int expectedValuesPerKey;
ArrayListSupplier(int expectedValuesPerKey) {
this.expectedValuesPerKey = checkNonnegative(expectedValuesPerKey, "expectedValuesPerKey");
}
Reported by PMD.
Line: 191
private final int expectedValuesPerKey;
ArrayListSupplier(int expectedValuesPerKey) {
this.expectedValuesPerKey = checkNonnegative(expectedValuesPerKey, "expectedValuesPerKey");
}
@Override
public List<V> get() {
return new ArrayList<V>(expectedValuesPerKey);
Reported by PMD.
Line: 216
}
}
private static final class HashSetSupplier<V extends @Nullable Object>
implements Supplier<Set<V>>, Serializable {
private final int expectedValuesPerKey;
HashSetSupplier(int expectedValuesPerKey) {
this.expectedValuesPerKey = checkNonnegative(expectedValuesPerKey, "expectedValuesPerKey");
Reported by PMD.
Line: 218
private static final class HashSetSupplier<V extends @Nullable Object>
implements Supplier<Set<V>>, Serializable {
private final int expectedValuesPerKey;
HashSetSupplier(int expectedValuesPerKey) {
this.expectedValuesPerKey = checkNonnegative(expectedValuesPerKey, "expectedValuesPerKey");
}
Reported by PMD.
Line: 230
}
}
private static final class LinkedHashSetSupplier<V extends @Nullable Object>
implements Supplier<Set<V>>, Serializable {
private final int expectedValuesPerKey;
LinkedHashSetSupplier(int expectedValuesPerKey) {
this.expectedValuesPerKey = checkNonnegative(expectedValuesPerKey, "expectedValuesPerKey");
Reported by PMD.
Line: 232
private static final class LinkedHashSetSupplier<V extends @Nullable Object>
implements Supplier<Set<V>>, Serializable {
private final int expectedValuesPerKey;
LinkedHashSetSupplier(int expectedValuesPerKey) {
this.expectedValuesPerKey = checkNonnegative(expectedValuesPerKey, "expectedValuesPerKey");
}
Reported by PMD.
Line: 244
}
}
private static final class TreeSetSupplier<V extends @Nullable Object>
implements Supplier<SortedSet<V>>, Serializable {
private final Comparator<? super V> comparator;
TreeSetSupplier(Comparator<? super V> comparator) {
this.comparator = checkNotNull(comparator);
Reported by PMD.
Line: 246
private static final class TreeSetSupplier<V extends @Nullable Object>
implements Supplier<SortedSet<V>>, Serializable {
private final Comparator<? super V> comparator;
TreeSetSupplier(Comparator<? super V> comparator) {
this.comparator = checkNotNull(comparator);
}
Reported by PMD.
guava/src/com/google/common/collect/ForwardingSortedMultiset.java
26 issues
Line: 51
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public abstract class ForwardingSortedMultiset<E extends @Nullable Object>
extends ForwardingMultiset<E> implements SortedMultiset<E> {
/** Constructor for use by subclasses. */
protected ForwardingSortedMultiset() {}
@Override
protected abstract SortedMultiset<E> delegate();
Reported by PMD.
Line: 60
@Override
public NavigableSet<E> elementSet() {
return delegate().elementSet();
}
/**
* A sensible implementation of {@link SortedMultiset#elementSet} in terms of the following
* methods: {@link SortedMultiset#clear}, {@link SortedMultiset#comparator}, {@link
Reported by PMD.
Line: 85
@Override
public Comparator<? super E> comparator() {
return delegate().comparator();
}
@Override
public SortedMultiset<E> descendingMultiset() {
return delegate().descendingMultiset();
Reported by PMD.
Line: 90
@Override
public SortedMultiset<E> descendingMultiset() {
return delegate().descendingMultiset();
}
/**
* A skeleton implementation of a descending multiset view. Normally, {@link
* #descendingMultiset()} will not reflect any changes you make to the behavior of methods such as
Reported by PMD.
Line: 118
@Override
@CheckForNull
public Entry<E> firstEntry() {
return delegate().firstEntry();
}
/**
* A sensible definition of {@link #firstEntry()} in terms of {@code entrySet().iterator()}.
*
Reported by PMD.
Line: 129
*/
@CheckForNull
protected Entry<E> standardFirstEntry() {
Iterator<Entry<E>> entryIterator = entrySet().iterator();
if (!entryIterator.hasNext()) {
return null;
}
Entry<E> entry = entryIterator.next();
return Multisets.immutableEntry(entry.getElement(), entry.getCount());
Reported by PMD.
Line: 134
return null;
}
Entry<E> entry = entryIterator.next();
return Multisets.immutableEntry(entry.getElement(), entry.getCount());
}
@Override
@CheckForNull
public Entry<E> lastEntry() {
Reported by PMD.
Line: 134
return null;
}
Entry<E> entry = entryIterator.next();
return Multisets.immutableEntry(entry.getElement(), entry.getCount());
}
@Override
@CheckForNull
public Entry<E> lastEntry() {
Reported by PMD.
Line: 140
@Override
@CheckForNull
public Entry<E> lastEntry() {
return delegate().lastEntry();
}
/**
* A sensible definition of {@link #lastEntry()} in terms of {@code
* descendingMultiset().entrySet().iterator()}.
Reported by PMD.
Line: 152
*/
@CheckForNull
protected Entry<E> standardLastEntry() {
Iterator<Entry<E>> entryIterator = descendingMultiset().entrySet().iterator();
if (!entryIterator.hasNext()) {
return null;
}
Entry<E> entry = entryIterator.next();
return Multisets.immutableEntry(entry.getElement(), entry.getCount());
Reported by PMD.
android/guava/src/com/google/common/math/PairedStats.java
26 issues
Line: 43
@Beta
@GwtIncompatible
@ElementTypesAreNonnullByDefault
public final class PairedStats implements Serializable {
private final Stats xStats;
private final Stats yStats;
private final double sumOfProductsOfDeltas;
Reported by PMD.
Line: 45
@ElementTypesAreNonnullByDefault
public final class PairedStats implements Serializable {
private final Stats xStats;
private final Stats yStats;
private final double sumOfProductsOfDeltas;
/**
* Internal constructor. Users should use {@link PairedStatsAccumulator#snapshot}.
Reported by PMD.
Line: 45
@ElementTypesAreNonnullByDefault
public final class PairedStats implements Serializable {
private final Stats xStats;
private final Stats yStats;
private final double sumOfProductsOfDeltas;
/**
* Internal constructor. Users should use {@link PairedStatsAccumulator#snapshot}.
Reported by PMD.
Line: 46
public final class PairedStats implements Serializable {
private final Stats xStats;
private final Stats yStats;
private final double sumOfProductsOfDeltas;
/**
* Internal constructor. Users should use {@link PairedStatsAccumulator#snapshot}.
*
Reported by PMD.
Line: 46
public final class PairedStats implements Serializable {
private final Stats xStats;
private final Stats yStats;
private final double sumOfProductsOfDeltas;
/**
* Internal constructor. Users should use {@link PairedStatsAccumulator#snapshot}.
*
Reported by PMD.
Line: 47
private final Stats xStats;
private final Stats yStats;
private final double sumOfProductsOfDeltas;
/**
* Internal constructor. Users should use {@link PairedStatsAccumulator#snapshot}.
*
* <p>To ensure that the created instance obeys its contract, the parameters should satisfy the
Reported by PMD.
Line: 47
private final Stats xStats;
private final Stats yStats;
private final double sumOfProductsOfDeltas;
/**
* Internal constructor. Users should use {@link PairedStatsAccumulator#snapshot}.
*
* <p>To ensure that the created instance obeys its contract, the parameters should satisfy the
Reported by PMD.
Line: 140
if (isNaN(sumOfProductsOfDeltas)) {
return NaN;
}
double xSumOfSquaresOfDeltas = xStats().sumOfSquaresOfDeltas();
double ySumOfSquaresOfDeltas = yStats().sumOfSquaresOfDeltas();
checkState(xSumOfSquaresOfDeltas > 0.0);
checkState(ySumOfSquaresOfDeltas > 0.0);
// The product of two positive numbers can be zero if the multiplication underflowed. We
// force a positive value by effectively rounding up to MIN_VALUE.
Reported by PMD.
Line: 141
return NaN;
}
double xSumOfSquaresOfDeltas = xStats().sumOfSquaresOfDeltas();
double ySumOfSquaresOfDeltas = yStats().sumOfSquaresOfDeltas();
checkState(xSumOfSquaresOfDeltas > 0.0);
checkState(ySumOfSquaresOfDeltas > 0.0);
// The product of two positive numbers can be zero if the multiplication underflowed. We
// force a positive value by effectively rounding up to MIN_VALUE.
double productOfSumsOfSquaresOfDeltas =
Reported by PMD.
Line: 188
return LinearTransformation.forNaN();
}
double xSumOfSquaresOfDeltas = xStats.sumOfSquaresOfDeltas();
if (xSumOfSquaresOfDeltas > 0.0) {
if (yStats.sumOfSquaresOfDeltas() > 0.0) {
return LinearTransformation.mapping(xStats.mean(), yStats.mean())
.withSlope(sumOfProductsOfDeltas / xSumOfSquaresOfDeltas);
} else {
return LinearTransformation.horizontal(yStats.mean());
Reported by PMD.
guava-testlib/src/com/google/common/collect/testing/TestsForMapsInJavaUtil.java
26 issues
Line: 52
* @author Kevin Bourrillion
*/
@GwtIncompatible
public class TestsForMapsInJavaUtil {
public static Test suite() {
return new TestsForMapsInJavaUtil().allTests();
}
Reported by PMD.
Line: 54
@GwtIncompatible
public class TestsForMapsInJavaUtil {
public static Test suite() {
return new TestsForMapsInJavaUtil().allTests();
}
public Test allTests() {
TestSuite suite = new TestSuite("java.util Maps");
Reported by PMD.
Line: 162
MapEntrySetTester.getSetValueWithNullValuesPresentMethod());
}
public Test testsForCheckedMap() {
return MapTestSuiteBuilder.using(
new TestStringMapGenerator() {
@Override
protected Map<String, String> create(Entry<String, String>[] entries) {
Map<String, String> map = populate(new HashMap<String, String>(), entries);
Reported by PMD.
Line: 187
.createTestSuite();
}
public Test testsForCheckedNavigableMap() {
return SortedMapTestSuiteBuilder.using(
new TestStringSortedMapGenerator() {
@Override
protected NavigableMap<String, String> create(Entry<String, String>[] entries) {
NavigableMap<String, String> map = populate(new TreeMap<String, String>(), entries);
Reported by PMD.
Line: 211
.createTestSuite();
}
public Test testsForCheckedSortedMap() {
return SortedMapTestSuiteBuilder.using(
new TestStringSortedMapGenerator() {
@Override
protected SortedMap<String, String> create(Entry<String, String>[] entries) {
SortedMap<String, String> map = populate(new TreeMap<String, String>(), entries);
Reported by PMD.
Line: 235
.createTestSuite();
}
public Test testsForEmptyMap() {
return MapTestSuiteBuilder.using(
new TestStringMapGenerator() {
@Override
protected Map<String, String> create(Entry<String, String>[] entries) {
return Collections.emptyMap();
Reported by PMD.
Line: 249
.createTestSuite();
}
public Test testsForEmptyNavigableMap() {
return MapTestSuiteBuilder.using(
new TestStringSortedMapGenerator() {
@Override
protected NavigableMap<String, String> create(Entry<String, String>[] entries) {
return Collections.emptyNavigableMap();
Reported by PMD.
Line: 263
.createTestSuite();
}
public Test testsForEmptySortedMap() {
return MapTestSuiteBuilder.using(
new TestStringSortedMapGenerator() {
@Override
protected SortedMap<String, String> create(Entry<String, String>[] entries) {
return Collections.emptySortedMap();
Reported by PMD.
Line: 277
.createTestSuite();
}
public Test testsForSingletonMap() {
return MapTestSuiteBuilder.using(
new TestStringMapGenerator() {
@Override
protected Map<String, String> create(Entry<String, String>[] entries) {
return Collections.singletonMap(entries[0].getKey(), entries[0].getValue());
Reported by PMD.
Line: 296
.createTestSuite();
}
public Test testsForHashMap() {
return MapTestSuiteBuilder.using(
new TestStringMapGenerator() {
@Override
protected Map<String, String> create(Entry<String, String>[] entries) {
return toHashMap(entries);
Reported by PMD.