The following issues were found
guava/src/com/google/common/util/concurrent/AbstractService.java
23 issues
Line: 54
*/
@GwtIncompatible
@ElementTypesAreNonnullByDefault
public abstract class AbstractService implements Service {
private static final ListenerCallQueue.Event<Listener> STARTING_EVENT =
new ListenerCallQueue.Event<Listener>() {
@Override
public void call(Listener listener) {
listener.starting();
Reported by PMD.
Line: 54
*/
@GwtIncompatible
@ElementTypesAreNonnullByDefault
public abstract class AbstractService implements Service {
private static final ListenerCallQueue.Event<Listener> STARTING_EVENT =
new ListenerCallQueue.Event<Listener>() {
@Override
public void call(Listener listener) {
listener.starting();
Reported by PMD.
Line: 121
};
}
private final Monitor monitor = new Monitor();
private final Guard isStartable = new IsStartableGuard();
@WeakOuter
private final class IsStartableGuard extends Guard {
Reported by PMD.
Line: 123
private final Monitor monitor = new Monitor();
private final Guard isStartable = new IsStartableGuard();
@WeakOuter
private final class IsStartableGuard extends Guard {
IsStartableGuard() {
super(AbstractService.this.monitor);
Reported by PMD.
Line: 137
}
}
private final Guard isStoppable = new IsStoppableGuard();
@WeakOuter
private final class IsStoppableGuard extends Guard {
IsStoppableGuard() {
super(AbstractService.this.monitor);
Reported by PMD.
Line: 147
@Override
public boolean isSatisfied() {
return state().compareTo(RUNNING) <= 0;
}
}
private final Guard hasReachedRunning = new HasReachedRunningGuard();
Reported by PMD.
Line: 151
}
}
private final Guard hasReachedRunning = new HasReachedRunningGuard();
@WeakOuter
private final class HasReachedRunningGuard extends Guard {
HasReachedRunningGuard() {
super(AbstractService.this.monitor);
Reported by PMD.
Line: 161
@Override
public boolean isSatisfied() {
return state().compareTo(RUNNING) >= 0;
}
}
private final Guard isStopped = new IsStoppedGuard();
Reported by PMD.
Line: 165
}
}
private final Guard isStopped = new IsStoppedGuard();
@WeakOuter
private final class IsStoppedGuard extends Guard {
IsStoppedGuard() {
super(AbstractService.this.monitor);
Reported by PMD.
Line: 175
@Override
public boolean isSatisfied() {
return state().compareTo(TERMINATED) >= 0;
}
}
/** The listeners to notify during a state transition. */
private final ListenerCallQueue<Listener> listeners = new ListenerCallQueue<>();
Reported by PMD.
guava/src/com/google/common/collect/RegularImmutableMultiset.java
23 issues
Line: 62
for (Entry<? extends E> entryWithWildcard : entries) {
@SuppressWarnings("unchecked") // safe because we only read from it
Entry<E> entry = (Entry<E>) entryWithWildcard;
E element = checkNotNull(entry.getElement());
int count = entry.getCount();
int hash = element.hashCode();
int bucket = Hashing.smear(hash) & mask;
ImmutableEntry<E> bucketHead = hashTable[bucket];
ImmutableEntry<E> newEntry;
Reported by PMD.
Line: 63
@SuppressWarnings("unchecked") // safe because we only read from it
Entry<E> entry = (Entry<E>) entryWithWildcard;
E element = checkNotNull(entry.getElement());
int count = entry.getCount();
int hash = element.hashCode();
int bucket = Hashing.smear(hash) & mask;
ImmutableEntry<E> bucketHead = hashTable[bucket];
ImmutableEntry<E> newEntry;
if (bucketHead == null) {
Reported by PMD.
Line: 64
Entry<E> entry = (Entry<E>) entryWithWildcard;
E element = checkNotNull(entry.getElement());
int count = entry.getCount();
int hash = element.hashCode();
int bucket = Hashing.smear(hash) & mask;
ImmutableEntry<E> bucketHead = hashTable[bucket];
ImmutableEntry<E> newEntry;
if (bucketHead == null) {
boolean canReuseEntry =
Reported by PMD.
Line: 72
boolean canReuseEntry =
entry instanceof ImmutableEntry && !(entry instanceof NonTerminalEntry);
newEntry =
canReuseEntry ? (ImmutableEntry<E>) entry : new ImmutableEntry<E>(element, count);
} else {
newEntry = new NonTerminalEntry<E>(element, count, bucketHead);
}
hashCode += hash ^ count;
entryArray[index++] = newEntry;
Reported by PMD.
Line: 74
newEntry =
canReuseEntry ? (ImmutableEntry<E>) entry : new ImmutableEntry<E>(element, count);
} else {
newEntry = new NonTerminalEntry<E>(element, count, bucketHead);
}
hashCode += hash ^ count;
entryArray[index++] = newEntry;
hashTable[bucket] = newEntry;
size += count;
Reported by PMD.
Line: 89
}
private static boolean hashFloodingDetected(@Nullable ImmutableEntry<?>[] hashTable) {
for (int i = 0; i < hashTable.length; i++) {
int bucketLength = 0;
for (ImmutableEntry<?> entry = hashTable[i]; entry != null; entry = entry.nextInBucket()) {
bucketLength++;
if (bucketLength > MAX_HASH_BUCKET_LENGTH) {
return true;
Reported by PMD.
Line: 91
private static boolean hashFloodingDetected(@Nullable ImmutableEntry<?>[] hashTable) {
for (int i = 0; i < hashTable.length; i++) {
int bucketLength = 0;
for (ImmutableEntry<?> entry = hashTable[i]; entry != null; entry = entry.nextInBucket()) {
bucketLength++;
if (bucketLength > MAX_HASH_BUCKET_LENGTH) {
return true;
}
}
Reported by PMD.
Line: 122
private final transient ImmutableEntry<E>[] entries;
private final transient @Nullable ImmutableEntry<?>[] hashTable;
private final transient int size;
private final transient int hashCode;
@LazyInit @CheckForNull private transient ImmutableSet<E> elementSet;
private RegularImmutableMultiset(
Reported by PMD.
Line: 123
private final transient ImmutableEntry<E>[] entries;
private final transient @Nullable ImmutableEntry<?>[] hashTable;
private final transient int size;
private final transient int hashCode;
@LazyInit @CheckForNull private transient ImmutableSet<E> elementSet;
private RegularImmutableMultiset(
ImmutableEntry<E>[] entries,
Reported by PMD.
Line: 125
private final transient int size;
private final transient int hashCode;
@LazyInit @CheckForNull private transient ImmutableSet<E> elementSet;
private RegularImmutableMultiset(
ImmutableEntry<E>[] entries,
@Nullable ImmutableEntry<?>[] hashTable,
int size,
Reported by PMD.
guava/src/com/google/common/util/concurrent/ThreadFactoryBuilder.java
23 issues
Line: 52
@GwtIncompatible
@ElementTypesAreNonnullByDefault
public final class ThreadFactoryBuilder {
@CheckForNull private String nameFormat = null;
@CheckForNull private Boolean daemon = null;
@CheckForNull private Integer priority = null;
@CheckForNull private UncaughtExceptionHandler uncaughtExceptionHandler = null;
@CheckForNull private ThreadFactory backingThreadFactory = null;
Reported by PMD.
Line: 52
@GwtIncompatible
@ElementTypesAreNonnullByDefault
public final class ThreadFactoryBuilder {
@CheckForNull private String nameFormat = null;
@CheckForNull private Boolean daemon = null;
@CheckForNull private Integer priority = null;
@CheckForNull private UncaughtExceptionHandler uncaughtExceptionHandler = null;
@CheckForNull private ThreadFactory backingThreadFactory = null;
Reported by PMD.
Line: 53
@ElementTypesAreNonnullByDefault
public final class ThreadFactoryBuilder {
@CheckForNull private String nameFormat = null;
@CheckForNull private Boolean daemon = null;
@CheckForNull private Integer priority = null;
@CheckForNull private UncaughtExceptionHandler uncaughtExceptionHandler = null;
@CheckForNull private ThreadFactory backingThreadFactory = null;
/** Creates a new {@link ThreadFactory} builder. */
Reported by PMD.
Line: 53
@ElementTypesAreNonnullByDefault
public final class ThreadFactoryBuilder {
@CheckForNull private String nameFormat = null;
@CheckForNull private Boolean daemon = null;
@CheckForNull private Integer priority = null;
@CheckForNull private UncaughtExceptionHandler uncaughtExceptionHandler = null;
@CheckForNull private ThreadFactory backingThreadFactory = null;
/** Creates a new {@link ThreadFactory} builder. */
Reported by PMD.
Line: 54
public final class ThreadFactoryBuilder {
@CheckForNull private String nameFormat = null;
@CheckForNull private Boolean daemon = null;
@CheckForNull private Integer priority = null;
@CheckForNull private UncaughtExceptionHandler uncaughtExceptionHandler = null;
@CheckForNull private ThreadFactory backingThreadFactory = null;
/** Creates a new {@link ThreadFactory} builder. */
public ThreadFactoryBuilder() {}
Reported by PMD.
Line: 54
public final class ThreadFactoryBuilder {
@CheckForNull private String nameFormat = null;
@CheckForNull private Boolean daemon = null;
@CheckForNull private Integer priority = null;
@CheckForNull private UncaughtExceptionHandler uncaughtExceptionHandler = null;
@CheckForNull private ThreadFactory backingThreadFactory = null;
/** Creates a new {@link ThreadFactory} builder. */
public ThreadFactoryBuilder() {}
Reported by PMD.
Line: 55
@CheckForNull private String nameFormat = null;
@CheckForNull private Boolean daemon = null;
@CheckForNull private Integer priority = null;
@CheckForNull private UncaughtExceptionHandler uncaughtExceptionHandler = null;
@CheckForNull private ThreadFactory backingThreadFactory = null;
/** Creates a new {@link ThreadFactory} builder. */
public ThreadFactoryBuilder() {}
Reported by PMD.
Line: 55
@CheckForNull private String nameFormat = null;
@CheckForNull private Boolean daemon = null;
@CheckForNull private Integer priority = null;
@CheckForNull private UncaughtExceptionHandler uncaughtExceptionHandler = null;
@CheckForNull private ThreadFactory backingThreadFactory = null;
/** Creates a new {@link ThreadFactory} builder. */
public ThreadFactoryBuilder() {}
Reported by PMD.
Line: 56
@CheckForNull private Boolean daemon = null;
@CheckForNull private Integer priority = null;
@CheckForNull private UncaughtExceptionHandler uncaughtExceptionHandler = null;
@CheckForNull private ThreadFactory backingThreadFactory = null;
/** Creates a new {@link ThreadFactory} builder. */
public ThreadFactoryBuilder() {}
/**
Reported by PMD.
Line: 56
@CheckForNull private Boolean daemon = null;
@CheckForNull private Integer priority = null;
@CheckForNull private UncaughtExceptionHandler uncaughtExceptionHandler = null;
@CheckForNull private ThreadFactory backingThreadFactory = null;
/** Creates a new {@link ThreadFactory} builder. */
public ThreadFactoryBuilder() {}
/**
Reported by PMD.
guava/src/com/google/common/math/DoubleMath.java
23 issues
Line: 184
*/
// #roundIntermediate, java.lang.Math.getExponent, com.google.common.math.DoubleUtils
@GwtIncompatible
public static BigInteger roundToBigInteger(double x, RoundingMode mode) {
x = roundIntermediate(x, mode);
if (MIN_LONG_AS_DOUBLE - x < 1.0 & x < MAX_LONG_AS_DOUBLE_PLUS_ONE) {
return BigInteger.valueOf((long) x);
}
int exponent = getExponent(x);
Reported by PMD.
Line: 50
*/
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public final class DoubleMath {
/*
* This method returns a value y such that rounding y DOWN (towards zero) gives the same result as
* rounding x according to the specified mode.
*/
@GwtIncompatible // #isMathematicalInteger, com.google.common.math.DoubleUtils
Reported by PMD.
Line: 50
*/
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public final class DoubleMath {
/*
* This method returns a value y such that rounding y DOWN (towards zero) gives the same result as
* rounding x according to the specified mode.
*/
@GwtIncompatible // #isMathematicalInteger, com.google.common.math.DoubleUtils
Reported by PMD.
Line: 50
*/
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public final class DoubleMath {
/*
* This method returns a value y such that rounding y DOWN (towards zero) gives the same result as
* rounding x according to the specified mode.
*/
@GwtIncompatible // #isMathematicalInteger, com.google.common.math.DoubleUtils
Reported by PMD.
Line: 56
* rounding x according to the specified mode.
*/
@GwtIncompatible // #isMathematicalInteger, com.google.common.math.DoubleUtils
static double roundIntermediate(double x, RoundingMode mode) {
if (!isFinite(x)) {
throw new ArithmeticException("input is infinite or NaN");
}
switch (mode) {
case UNNECESSARY:
Reported by PMD.
Line: 56
* rounding x according to the specified mode.
*/
@GwtIncompatible // #isMathematicalInteger, com.google.common.math.DoubleUtils
static double roundIntermediate(double x, RoundingMode mode) {
if (!isFinite(x)) {
throw new ArithmeticException("input is infinite or NaN");
}
switch (mode) {
case UNNECESSARY:
Reported by PMD.
Line: 95
case HALF_UP:
{
double z = rint(x);
if (abs(x - z) == 0.5) {
return x + copySign(0.5, x);
} else {
return z;
}
}
Reported by PMD.
Line: 105
case HALF_DOWN:
{
double z = rint(x);
if (abs(x - z) == 0.5) {
return x;
} else {
return z;
}
}
Reported by PMD.
Line: 191
}
int exponent = getExponent(x);
long significand = getSignificand(x);
BigInteger result = BigInteger.valueOf(significand).shiftLeft(exponent - SIGNIFICAND_BITS);
return (x < 0) ? result.negate() : result;
}
/**
* Returns {@code true} if {@code x} is exactly equal to {@code 2^k} for some finite integer
Reported by PMD.
Line: 192
int exponent = getExponent(x);
long significand = getSignificand(x);
BigInteger result = BigInteger.valueOf(significand).shiftLeft(exponent - SIGNIFICAND_BITS);
return (x < 0) ? result.negate() : result;
}
/**
* Returns {@code true} if {@code x} is exactly equal to {@code 2^k} for some finite integer
* {@code k}.
Reported by PMD.
guava/src/com/google/common/graph/StandardNetwork.java
23 issues
Line: 52
* @param <E> Edge parameter type
*/
@ElementTypesAreNonnullByDefault
class StandardNetwork<N, E> extends AbstractNetwork<N, E> {
private final boolean isDirected;
private final boolean allowsParallelEdges;
private final boolean allowsSelfLoops;
private final ElementOrder<N> nodeOrder;
private final ElementOrder<E> edgeOrder;
Reported by PMD.
Line: 53
*/
@ElementTypesAreNonnullByDefault
class StandardNetwork<N, E> extends AbstractNetwork<N, E> {
private final boolean isDirected;
private final boolean allowsParallelEdges;
private final boolean allowsSelfLoops;
private final ElementOrder<N> nodeOrder;
private final ElementOrder<E> edgeOrder;
Reported by PMD.
Line: 53
*/
@ElementTypesAreNonnullByDefault
class StandardNetwork<N, E> extends AbstractNetwork<N, E> {
private final boolean isDirected;
private final boolean allowsParallelEdges;
private final boolean allowsSelfLoops;
private final ElementOrder<N> nodeOrder;
private final ElementOrder<E> edgeOrder;
Reported by PMD.
Line: 54
@ElementTypesAreNonnullByDefault
class StandardNetwork<N, E> extends AbstractNetwork<N, E> {
private final boolean isDirected;
private final boolean allowsParallelEdges;
private final boolean allowsSelfLoops;
private final ElementOrder<N> nodeOrder;
private final ElementOrder<E> edgeOrder;
final MapIteratorCache<N, NetworkConnections<N, E>> nodeConnections;
Reported by PMD.
Line: 54
@ElementTypesAreNonnullByDefault
class StandardNetwork<N, E> extends AbstractNetwork<N, E> {
private final boolean isDirected;
private final boolean allowsParallelEdges;
private final boolean allowsSelfLoops;
private final ElementOrder<N> nodeOrder;
private final ElementOrder<E> edgeOrder;
final MapIteratorCache<N, NetworkConnections<N, E>> nodeConnections;
Reported by PMD.
Line: 55
class StandardNetwork<N, E> extends AbstractNetwork<N, E> {
private final boolean isDirected;
private final boolean allowsParallelEdges;
private final boolean allowsSelfLoops;
private final ElementOrder<N> nodeOrder;
private final ElementOrder<E> edgeOrder;
final MapIteratorCache<N, NetworkConnections<N, E>> nodeConnections;
Reported by PMD.
Line: 55
class StandardNetwork<N, E> extends AbstractNetwork<N, E> {
private final boolean isDirected;
private final boolean allowsParallelEdges;
private final boolean allowsSelfLoops;
private final ElementOrder<N> nodeOrder;
private final ElementOrder<E> edgeOrder;
final MapIteratorCache<N, NetworkConnections<N, E>> nodeConnections;
Reported by PMD.
Line: 56
private final boolean isDirected;
private final boolean allowsParallelEdges;
private final boolean allowsSelfLoops;
private final ElementOrder<N> nodeOrder;
private final ElementOrder<E> edgeOrder;
final MapIteratorCache<N, NetworkConnections<N, E>> nodeConnections;
// We could make this a Map<E, EndpointPair<N>>. It would make incidentNodes(edge) slightly
Reported by PMD.
Line: 56
private final boolean isDirected;
private final boolean allowsParallelEdges;
private final boolean allowsSelfLoops;
private final ElementOrder<N> nodeOrder;
private final ElementOrder<E> edgeOrder;
final MapIteratorCache<N, NetworkConnections<N, E>> nodeConnections;
// We could make this a Map<E, EndpointPair<N>>. It would make incidentNodes(edge) slightly
Reported by PMD.
Line: 57
private final boolean allowsParallelEdges;
private final boolean allowsSelfLoops;
private final ElementOrder<N> nodeOrder;
private final ElementOrder<E> edgeOrder;
final MapIteratorCache<N, NetworkConnections<N, E>> nodeConnections;
// We could make this a Map<E, EndpointPair<N>>. It would make incidentNodes(edge) slightly
// faster, but also make Networks consume 5 to 20+% (increasing with average degree) more memory.
Reported by PMD.
guava/src/com/google/common/util/concurrent/SequentialExecutor.java
23 issues
Line: 237
try {
task.run();
} catch (RuntimeException e) {
log.log(Level.SEVERE, "Exception while executing runnable " + task, e);
} finally {
task = null;
}
}
} finally {
Reported by PMD.
Line: 66
}
/** Underlying executor that all submitted Runnable objects are run on. */
private final Executor executor;
@GuardedBy("queue")
private final Deque<Runnable> queue = new ArrayDeque<>();
/** see {@link WorkerRunningState} */
Reported by PMD.
Line: 69
private final Executor executor;
@GuardedBy("queue")
private final Deque<Runnable> queue = new ArrayDeque<>();
/** see {@link WorkerRunningState} */
@GuardedBy("queue")
private WorkerRunningState workerRunningState = IDLE;
Reported by PMD.
Line: 73
/** see {@link WorkerRunningState} */
@GuardedBy("queue")
private WorkerRunningState workerRunningState = IDLE;
/**
* This counter prevents an ABA issue where a thread may successfully schedule the worker, the
* worker runs and exhausts the queue, another thread enqueues a task and fails to schedule the
* worker, and then the first thread's call to delegate.execute() returns. Without this counter,
Reported by PMD.
Line: 83
* scheduled again for future submissions.
*/
@GuardedBy("queue")
private long workerRunCount = 0;
@RetainedWith private final QueueWorker worker = new QueueWorker();
/** Use {@link MoreExecutors#newSequentialExecutor} */
SequentialExecutor(Executor executor) {
Reported by PMD.
Line: 83
* scheduled again for future submissions.
*/
@GuardedBy("queue")
private long workerRunCount = 0;
@RetainedWith private final QueueWorker worker = new QueueWorker();
/** Use {@link MoreExecutors#newSequentialExecutor} */
SequentialExecutor(Executor executor) {
Reported by PMD.
Line: 85
@GuardedBy("queue")
private long workerRunCount = 0;
@RetainedWith private final QueueWorker worker = new QueueWorker();
/** Use {@link MoreExecutors#newSequentialExecutor} */
SequentialExecutor(Executor executor) {
this.executor = Preconditions.checkNotNull(executor);
}
Reported by PMD.
Line: 99
* execution of tasks will stop until a call to this method is made.
*/
@Override
public void execute(final Runnable task) {
checkNotNull(task);
final Runnable submittedTask;
final long oldRunCount;
synchronized (queue) {
// If the worker is already running (or execute() on the delegate returned successfully, and
Reported by PMD.
Line: 137
try {
executor.execute(worker);
} catch (RuntimeException | Error t) {
synchronized (queue) {
boolean removed =
(workerRunningState == IDLE || workerRunningState == QUEUING)
&& queue.removeLastOccurrence(submittedTask);
// If the delegate is directExecutor(), the submitted runnable could have thrown a REE. But
Reported by PMD.
Line: 144
&& queue.removeLastOccurrence(submittedTask);
// If the delegate is directExecutor(), the submitted runnable could have thrown a REE. But
// that's handled by the log check that catches RuntimeExceptions in the queue worker.
if (!(t instanceof RejectedExecutionException) || removed) {
throw t;
}
}
return;
}
Reported by PMD.
guava-tests/test/com/google/common/util/concurrent/SupplementalMonitorTest.java
23 issues
Line: 39
public class SupplementalMonitorTest extends TestCase {
public void testLeaveWithoutEnterThrowsIMSE() {
Monitor monitor = new Monitor();
try {
monitor.leave();
fail("expected IllegalMonitorStateException");
} catch (IllegalMonitorStateException expected) {
Reported by PMD.
Line: 43
Monitor monitor = new Monitor();
try {
monitor.leave();
fail("expected IllegalMonitorStateException");
} catch (IllegalMonitorStateException expected) {
}
}
public void testGetWaitQueueLengthWithWrongMonitorThrowsIMSE() {
Reported by PMD.
Line: 48
}
}
public void testGetWaitQueueLengthWithWrongMonitorThrowsIMSE() {
Monitor monitor1 = new Monitor();
Monitor monitor2 = new Monitor();
FlagGuard guard = new FlagGuard(monitor2);
try {
monitor1.getWaitQueueLength(guard);
Reported by PMD.
Line: 54
FlagGuard guard = new FlagGuard(monitor2);
try {
monitor1.getWaitQueueLength(guard);
fail("expected IllegalMonitorStateException");
} catch (IllegalMonitorStateException expected) {
}
}
public void testHasWaitersWithWrongMonitorThrowsIMSE() {
Reported by PMD.
Line: 59
}
}
public void testHasWaitersWithWrongMonitorThrowsIMSE() {
Monitor monitor1 = new Monitor();
Monitor monitor2 = new Monitor();
FlagGuard guard = new FlagGuard(monitor2);
try {
monitor1.hasWaiters(guard);
Reported by PMD.
Line: 65
FlagGuard guard = new FlagGuard(monitor2);
try {
monitor1.hasWaiters(guard);
fail("expected IllegalMonitorStateException");
} catch (IllegalMonitorStateException expected) {
}
}
public void testNullMonitorInGuardConstructorThrowsNPE() {
Reported by PMD.
Line: 70
}
}
public void testNullMonitorInGuardConstructorThrowsNPE() {
try {
new FlagGuard(null);
fail("expected NullPointerException");
} catch (NullPointerException expected) {
}
Reported by PMD.
Line: 73
public void testNullMonitorInGuardConstructorThrowsNPE() {
try {
new FlagGuard(null);
fail("expected NullPointerException");
} catch (NullPointerException expected) {
}
}
public void testIsFair() {
Reported by PMD.
Line: 74
try {
new FlagGuard(null);
fail("expected NullPointerException");
} catch (NullPointerException expected) {
}
}
public void testIsFair() {
assertTrue(new Monitor(true).isFair());
Reported by PMD.
Line: 74
try {
new FlagGuard(null);
fail("expected NullPointerException");
} catch (NullPointerException expected) {
}
}
public void testIsFair() {
assertTrue(new Monitor(true).isFair());
Reported by PMD.
guava/src/com/google/common/collect/ImmutableSortedSet.java
23 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.ObjectArrays.checkElementsNotNull;
Reported by PMD.
Line: 66
@GwtCompatible(serializable = true, emulated = true)
@SuppressWarnings("serial") // we're overriding default serialization
@ElementTypesAreNonnullByDefault
public abstract class ImmutableSortedSet<E> extends ImmutableSortedSetFauxverideShim<E>
implements NavigableSet<E>, SortedIterable<E> {
static final int SPLITERATOR_CHARACTERISTICS =
ImmutableSet.SPLITERATOR_CHARACTERISTICS | Spliterator.SORTED;
/**
Reported by PMD.
Line: 67
@SuppressWarnings("serial") // we're overriding default serialization
@ElementTypesAreNonnullByDefault
public abstract class ImmutableSortedSet<E> extends ImmutableSortedSetFauxverideShim<E>
implements NavigableSet<E>, SortedIterable<E> {
static final int SPLITERATOR_CHARACTERISTICS =
ImmutableSet.SPLITERATOR_CHARACTERISTICS | Spliterator.SORTED;
/**
* Returns a {@code Collector} that accumulates the input elements into a new {@code
Reported by PMD.
Line: 86
}
static <E> RegularImmutableSortedSet<E> emptySet(Comparator<? super E> comparator) {
if (Ordering.natural().equals(comparator)) {
return (RegularImmutableSortedSet<E>) RegularImmutableSortedSet.NATURAL_EMPTY_SET;
} else {
return new RegularImmutableSortedSet<E>(ImmutableList.<E>of(), comparator);
}
}
Reported by PMD.
Line: 114
*
* @throws NullPointerException if any element is null
*/
@SuppressWarnings("unchecked")
public static <E extends Comparable<? super E>> ImmutableSortedSet<E> of(E e1, E e2) {
return construct(Ordering.natural(), 2, e1, e2);
}
/**
Reported by PMD.
Line: 303
if (hasSameComparator && (elements instanceof ImmutableSortedSet)) {
@SuppressWarnings("unchecked")
ImmutableSortedSet<E> original = (ImmutableSortedSet<E>) elements;
if (!original.isPartialView()) {
return original;
}
}
@SuppressWarnings("unchecked") // elements only contains E's; it's safe.
E[] array = (E[]) Iterables.toArray(elements);
Reported by PMD.
Line: 349
public static <E> ImmutableSortedSet<E> copyOfSorted(SortedSet<E> sortedSet) {
Comparator<? super E> comparator = SortedIterables.comparator(sortedSet);
ImmutableList<E> list = ImmutableList.copyOf(sortedSet);
if (list.isEmpty()) {
return emptySet(comparator);
} else {
return new RegularImmutableSortedSet<E>(list, comparator);
}
}
Reported by PMD.
Line: 590
// that are spec'd to throw CCE and NPE should call this.
@SuppressWarnings({"unchecked", "nullness"})
Comparator<@Nullable Object> unsafeComparator = (Comparator<@Nullable Object>) comparator;
return unsafeComparator.compare(a, b);
}
final transient Comparator<? super E> comparator;
ImmutableSortedSet(Comparator<? super E> comparator) {
Reported by PMD.
Line: 593
return unsafeComparator.compare(a, b);
}
final transient Comparator<? super E> comparator;
ImmutableSortedSet(Comparator<? super E> comparator) {
this.comparator = comparator;
}
Reported by PMD.
Line: 698
@Override
@CheckForNull
public E lower(E e) {
return Iterators.getNext(headSet(e, false).descendingIterator(), null);
}
/** @since 12.0 */
@Override
@CheckForNull
Reported by PMD.
guava/src/com/google/common/collect/ArrayTable.java
23 issues
Line: 95
@Beta
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public final class ArrayTable<R, C, V> extends AbstractTable<R, C, @Nullable V>
implements Serializable {
/**
* Creates an {@code ArrayTable} filled with {@code null}.
*
Reported by PMD.
Line: 96
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public final class ArrayTable<R, C, V> extends AbstractTable<R, C, @Nullable V>
implements Serializable {
/**
* Creates an {@code ArrayTable} filled with {@code null}.
*
* @param rowKeys row keys that may be stored in the generated table
Reported by PMD.
Line: 142
: new ArrayTable<R, C, V>(table);
}
private final ImmutableList<R> rowList;
private final ImmutableList<C> columnList;
// TODO(jlevy): Add getters returning rowKeyToIndex and columnKeyToIndex?
private final ImmutableMap<R, Integer> rowKeyToIndex;
private final ImmutableMap<C, Integer> columnKeyToIndex;
Reported by PMD.
Line: 143
}
private final ImmutableList<R> rowList;
private final ImmutableList<C> columnList;
// TODO(jlevy): Add getters returning rowKeyToIndex and columnKeyToIndex?
private final ImmutableMap<R, Integer> rowKeyToIndex;
private final ImmutableMap<C, Integer> columnKeyToIndex;
private final @Nullable V[][] array;
Reported by PMD.
Line: 146
private final ImmutableList<C> columnList;
// TODO(jlevy): Add getters returning rowKeyToIndex and columnKeyToIndex?
private final ImmutableMap<R, Integer> rowKeyToIndex;
private final ImmutableMap<C, Integer> columnKeyToIndex;
private final @Nullable V[][] array;
private ArrayTable(Iterable<? extends R> rowKeys, Iterable<? extends C> columnKeys) {
this.rowList = ImmutableList.copyOf(rowKeys);
Reported by PMD.
Line: 147
// TODO(jlevy): Add getters returning rowKeyToIndex and columnKeyToIndex?
private final ImmutableMap<R, Integer> rowKeyToIndex;
private final ImmutableMap<C, Integer> columnKeyToIndex;
private final @Nullable V[][] array;
private ArrayTable(Iterable<? extends R> rowKeys, Iterable<? extends C> columnKeys) {
this.rowList = ImmutableList.copyOf(rowKeys);
this.columnList = ImmutableList.copyOf(columnKeys);
Reported by PMD.
Line: 148
// TODO(jlevy): Add getters returning rowKeyToIndex and columnKeyToIndex?
private final ImmutableMap<R, Integer> rowKeyToIndex;
private final ImmutableMap<C, Integer> columnKeyToIndex;
private final @Nullable V[][] array;
private ArrayTable(Iterable<? extends R> rowKeys, Iterable<? extends C> columnKeys) {
this.rowList = ImmutableList.copyOf(rowKeys);
this.columnList = ImmutableList.copyOf(columnKeys);
checkArgument(rowList.isEmpty() == columnList.isEmpty());
Reported by PMD.
Line: 193
private abstract static class ArrayMap<K, V extends @Nullable Object>
extends IteratorBasedAbstractMap<K, V> {
private final ImmutableMap<K, Integer> keyIndex;
private ArrayMap(ImmutableMap<K, Integer> keyIndex) {
this.keyIndex = keyIndex;
}
Reported by PMD.
Line: 205
}
K getKey(int index) {
return keyIndex.keySet().asList().get(index);
}
abstract String getKeyRole();
@ParametricNullness
Reported by PMD.
Line: 205
}
K getKey(int index) {
return keyIndex.keySet().asList().get(index);
}
abstract String getKeyRole();
@ParametricNullness
Reported by PMD.
guava/src/com/google/common/collect/AbstractMultimap.java
23 issues
Line: 44
@GwtCompatible
@ElementTypesAreNonnullByDefault
abstract class AbstractMultimap<K extends @Nullable Object, V extends @Nullable Object>
implements Multimap<K, V> {
@Override
public boolean isEmpty() {
return size() == 0;
}
Reported by PMD.
Line: 52
@Override
public boolean containsValue(@CheckForNull Object value) {
for (Collection<V> collection : asMap().values()) {
if (collection.contains(value)) {
return true;
}
}
Reported by PMD.
Line: 63
@Override
public boolean containsEntry(@CheckForNull Object key, @CheckForNull Object value) {
Collection<V> collection = asMap().get(key);
return collection != null && collection.contains(value);
}
@CanIgnoreReturnValue
@Override
Reported by PMD.
Line: 64
@Override
public boolean containsEntry(@CheckForNull Object key, @CheckForNull Object value) {
Collection<V> collection = asMap().get(key);
return collection != null && collection.contains(value);
}
@CanIgnoreReturnValue
@Override
public boolean remove(@CheckForNull Object key, @CheckForNull Object value) {
Reported by PMD.
Line: 70
@CanIgnoreReturnValue
@Override
public boolean remove(@CheckForNull Object key, @CheckForNull Object value) {
Collection<V> collection = asMap().get(key);
return collection != null && collection.remove(value);
}
@CanIgnoreReturnValue
@Override
Reported by PMD.
Line: 71
@Override
public boolean remove(@CheckForNull Object key, @CheckForNull Object value) {
Collection<V> collection = asMap().get(key);
return collection != null && collection.remove(value);
}
@CanIgnoreReturnValue
@Override
public boolean put(@ParametricNullness K key, @ParametricNullness V value) {
Reported by PMD.
Line: 77
@CanIgnoreReturnValue
@Override
public boolean put(@ParametricNullness K key, @ParametricNullness V value) {
return get(key).add(value);
}
@CanIgnoreReturnValue
@Override
public boolean putAll(@ParametricNullness K key, Iterable<? extends V> values) {
Reported by PMD.
Line: 88
// and we only call get(key) if values is nonempty
if (values instanceof Collection) {
Collection<? extends V> valueCollection = (Collection<? extends V>) values;
return !valueCollection.isEmpty() && get(key).addAll(valueCollection);
} else {
Iterator<? extends V> valueItr = values.iterator();
return valueItr.hasNext() && Iterators.addAll(get(key), valueItr);
}
}
Reported by PMD.
Line: 88
// and we only call get(key) if values is nonempty
if (values instanceof Collection) {
Collection<? extends V> valueCollection = (Collection<? extends V>) values;
return !valueCollection.isEmpty() && get(key).addAll(valueCollection);
} else {
Iterator<? extends V> valueItr = values.iterator();
return valueItr.hasNext() && Iterators.addAll(get(key), valueItr);
}
}
Reported by PMD.
Line: 114
return result;
}
@LazyInit @CheckForNull private transient Collection<Entry<K, V>> entries;
@Override
public Collection<Entry<K, V>> entries() {
Collection<Entry<K, V>> result = entries;
return (result == null) ? entries = createEntries() : result;
Reported by PMD.