The following issues were found
guava-tests/benchmark/com/google/common/util/concurrent/MonitorBasedPriorityBlockingQueue.java
30 issues
Line: 417
*/
@Override
public int drainTo(Collection<? super E> c) {
if (c == null) throw new NullPointerException();
if (c == this) throw new IllegalArgumentException();
final Monitor monitor = this.monitor;
monitor.enter();
try {
int n = 0;
Reported by PMD.
Line: 442
*/
@Override
public int drainTo(Collection<? super E> c, int maxElements) {
if (c == null) throw new NullPointerException();
if (c == this) throw new IllegalArgumentException();
if (maxElements <= 0) return 0;
final Monitor monitor = this.monitor;
monitor.enter();
try {
Reported by PMD.
Line: 81
*/
@CanIgnoreReturnValue // TODO(cpovirk): Consider being more strict.
public class MonitorBasedPriorityBlockingQueue<E> extends AbstractQueue<E>
implements BlockingQueue<E> {
// Based on revision 1.55 of PriorityBlockingQueue by Doug Lea, from
// http://gee.cs.oswego.edu/cgi-bin/viewcvs.cgi/jsr166/src/main/java/util/concurrent/
private static final long serialVersionUID = 5595510919245408276L;
Reported by PMD.
Line: 88
private static final long serialVersionUID = 5595510919245408276L;
final PriorityQueue<E> q;
final Monitor monitor = new Monitor(true);
private final Monitor.Guard notEmpty =
new Monitor.Guard(monitor) {
@Override
public boolean isSatisfied() {
Reported by PMD.
Line: 89
private static final long serialVersionUID = 5595510919245408276L;
final PriorityQueue<E> q;
final Monitor monitor = new Monitor(true);
private final Monitor.Guard notEmpty =
new Monitor.Guard(monitor) {
@Override
public boolean isSatisfied() {
return !q.isEmpty();
Reported by PMD.
Line: 90
final PriorityQueue<E> q;
final Monitor monitor = new Monitor(true);
private final Monitor.Guard notEmpty =
new Monitor.Guard(monitor) {
@Override
public boolean isSatisfied() {
return !q.isEmpty();
}
Reported by PMD.
Line: 172
@Override
public boolean offer(E e) {
final Monitor monitor = this.monitor;
monitor.enter();
try {
boolean ok = q.offer(e);
if (!ok) {
throw new AssertionError();
}
Reported by PMD.
Line: 219
@Override
public E poll() {
final Monitor monitor = this.monitor;
monitor.enter();
try {
return q.poll();
} finally {
monitor.leave();
}
Reported by PMD.
Line: 230
@Override
public E poll(long timeout, TimeUnit unit) throws InterruptedException {
final Monitor monitor = this.monitor;
if (monitor.enterWhen(notEmpty, timeout, unit)) {
try {
return q.poll();
} finally {
monitor.leave();
}
Reported by PMD.
Line: 244
@Override
public E take() throws InterruptedException {
final Monitor monitor = this.monitor;
monitor.enterWhen(notEmpty);
try {
return q.poll();
} finally {
monitor.leave();
}
Reported by PMD.
android/guava/src/com/google/common/base/Predicates.java
30 issues
Line: 15
* the License.
*/
package com.google.common.base;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
Reported by PMD.
Line: 44
*/
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public final class Predicates {
private Predicates() {}
// TODO(kevinb): considering having these implement a VisitablePredicate
// interface which specifies an accept(PredicateVisitor) method.
Reported by PMD.
Line: 53
/** Returns a predicate that always evaluates to {@code true}. */
@GwtCompatible(serializable = true)
public static <T extends @Nullable Object> Predicate<T> alwaysTrue() {
return ObjectPredicate.ALWAYS_TRUE.withNarrowedType();
}
/** Returns a predicate that always evaluates to {@code false}. */
@GwtCompatible(serializable = true)
public static <T extends @Nullable Object> Predicate<T> alwaysFalse() {
Reported by PMD.
Line: 59
/** Returns a predicate that always evaluates to {@code false}. */
@GwtCompatible(serializable = true)
public static <T extends @Nullable Object> Predicate<T> alwaysFalse() {
return ObjectPredicate.ALWAYS_FALSE.withNarrowedType();
}
/**
* Returns a predicate that evaluates to {@code true} if the object reference being tested is
* null.
Reported by PMD.
Line: 68
*/
@GwtCompatible(serializable = true)
public static <T extends @Nullable Object> Predicate<T> isNull() {
return ObjectPredicate.IS_NULL.withNarrowedType();
}
/**
* Returns a predicate that evaluates to {@code true} if the object reference being tested is not
* null.
Reported by PMD.
Line: 77
*/
@GwtCompatible(serializable = true)
public static <T extends @Nullable Object> Predicate<T> notNull() {
return ObjectPredicate.NOT_NULL.withNarrowedType();
}
/**
* Returns a predicate that evaluates to {@code true} if the given predicate evaluates to {@code
* false}.
Reported by PMD.
Line: 317
/** @see Predicates#not(Predicate) */
private static class NotPredicate<T extends @Nullable Object>
implements Predicate<T>, Serializable {
final Predicate<T> predicate;
NotPredicate(Predicate<T> predicate) {
this.predicate = checkNotNull(predicate);
}
Reported by PMD.
Line: 353
/** @see Predicates#and(Iterable) */
private static class AndPredicate<T extends @Nullable Object>
implements Predicate<T>, Serializable {
private final List<? extends Predicate<? super T>> components;
private AndPredicate(List<? extends Predicate<? super T>> components) {
this.components = components;
}
Reported by PMD.
Line: 362
@Override
public boolean apply(@ParametricNullness T t) {
// Avoid using the Iterator to avoid generating garbage (issue 820).
for (int i = 0; i < components.size(); i++) {
if (!components.get(i).apply(t)) {
return false;
}
}
return true;
Reported by PMD.
Line: 363
public boolean apply(@ParametricNullness T t) {
// Avoid using the Iterator to avoid generating garbage (issue 820).
for (int i = 0; i < components.size(); i++) {
if (!components.get(i).apply(t)) {
return false;
}
}
return true;
}
Reported by PMD.
android/guava-tests/test/com/google/common/collect/TransposedTableTest.java
30 issues
Line: 33
protected Table<String, Integer, Character> create(Object... data) {
Table<Integer, String, Character> original = HashBasedTable.create();
Table<String, Integer, Character> table = Tables.transpose(original);
table.clear();
populate(table, data);
return table;
}
public void testTransposeTransposed() {
Reported by PMD.
Line: 38
return table;
}
public void testTransposeTransposed() {
Table<Integer, String, Character> original = HashBasedTable.create();
assertSame(original, Tables.transpose(Tables.transpose(original)));
}
public void testPutOriginalModifiesTranspose() {
Reported by PMD.
Line: 43
assertSame(original, Tables.transpose(Tables.transpose(original)));
}
public void testPutOriginalModifiesTranspose() {
Table<Integer, String, Character> original = HashBasedTable.create();
Table<String, Integer, Character> transpose = Tables.transpose(original);
original.put(1, "foo", 'a');
assertEquals((Character) 'a', transpose.get("foo", 1));
}
Reported by PMD.
Line: 46
public void testPutOriginalModifiesTranspose() {
Table<Integer, String, Character> original = HashBasedTable.create();
Table<String, Integer, Character> transpose = Tables.transpose(original);
original.put(1, "foo", 'a');
assertEquals((Character) 'a', transpose.get("foo", 1));
}
public void testPutTransposeModifiesOriginal() {
Table<Integer, String, Character> original = HashBasedTable.create();
Reported by PMD.
Line: 46
public void testPutOriginalModifiesTranspose() {
Table<Integer, String, Character> original = HashBasedTable.create();
Table<String, Integer, Character> transpose = Tables.transpose(original);
original.put(1, "foo", 'a');
assertEquals((Character) 'a', transpose.get("foo", 1));
}
public void testPutTransposeModifiesOriginal() {
Table<Integer, String, Character> original = HashBasedTable.create();
Reported by PMD.
Line: 47
Table<Integer, String, Character> original = HashBasedTable.create();
Table<String, Integer, Character> transpose = Tables.transpose(original);
original.put(1, "foo", 'a');
assertEquals((Character) 'a', transpose.get("foo", 1));
}
public void testPutTransposeModifiesOriginal() {
Table<Integer, String, Character> original = HashBasedTable.create();
Table<String, Integer, Character> transpose = Tables.transpose(original);
Reported by PMD.
Line: 50
assertEquals((Character) 'a', transpose.get("foo", 1));
}
public void testPutTransposeModifiesOriginal() {
Table<Integer, String, Character> original = HashBasedTable.create();
Table<String, Integer, Character> transpose = Tables.transpose(original);
transpose.put("foo", 1, 'a');
assertEquals((Character) 'a', original.get(1, "foo"));
}
Reported by PMD.
Line: 53
public void testPutTransposeModifiesOriginal() {
Table<Integer, String, Character> original = HashBasedTable.create();
Table<String, Integer, Character> transpose = Tables.transpose(original);
transpose.put("foo", 1, 'a');
assertEquals((Character) 'a', original.get(1, "foo"));
}
public void testTransposedViews() {
Table<Integer, String, Character> original = HashBasedTable.create();
Reported by PMD.
Line: 54
Table<Integer, String, Character> original = HashBasedTable.create();
Table<String, Integer, Character> transpose = Tables.transpose(original);
transpose.put("foo", 1, 'a');
assertEquals((Character) 'a', original.get(1, "foo"));
}
public void testTransposedViews() {
Table<Integer, String, Character> original = HashBasedTable.create();
Table<String, Integer, Character> transpose = Tables.transpose(original);
Reported by PMD.
Line: 57
assertEquals((Character) 'a', original.get(1, "foo"));
}
public void testTransposedViews() {
Table<Integer, String, Character> original = HashBasedTable.create();
Table<String, Integer, Character> transpose = Tables.transpose(original);
original.put(1, "foo", 'a');
assertSame(original.columnKeySet(), transpose.rowKeySet());
assertSame(original.rowKeySet(), transpose.columnKeySet());
Reported by PMD.
android/guava-tests/test/com/google/common/collect/SingletonImmutableTableTest.java
30 issues
Line: 32
* @author Gregory Kick
*/
@GwtCompatible(emulated = true)
public class SingletonImmutableTableTest extends AbstractImmutableTableTest {
private final ImmutableTable<Character, Integer, String> testTable =
new SingletonImmutableTable<>('a', 1, "blah");
public void testHashCode() {
assertEquals(Objects.hashCode('a', 1, "blah"), testTable.hashCode());
Reported by PMD.
Line: 33
*/
@GwtCompatible(emulated = true)
public class SingletonImmutableTableTest extends AbstractImmutableTableTest {
private final ImmutableTable<Character, Integer, String> testTable =
new SingletonImmutableTable<>('a', 1, "blah");
public void testHashCode() {
assertEquals(Objects.hashCode('a', 1, "blah"), testTable.hashCode());
}
Reported by PMD.
Line: 34
@GwtCompatible(emulated = true)
public class SingletonImmutableTableTest extends AbstractImmutableTableTest {
private final ImmutableTable<Character, Integer, String> testTable =
new SingletonImmutableTable<>('a', 1, "blah");
public void testHashCode() {
assertEquals(Objects.hashCode('a', 1, "blah"), testTable.hashCode());
}
Reported by PMD.
Line: 36
private final ImmutableTable<Character, Integer, String> testTable =
new SingletonImmutableTable<>('a', 1, "blah");
public void testHashCode() {
assertEquals(Objects.hashCode('a', 1, "blah"), testTable.hashCode());
}
public void testCellSet() {
assertEquals(ImmutableSet.of(Tables.immutableCell('a', 1, "blah")), testTable.cellSet());
Reported by PMD.
Line: 40
assertEquals(Objects.hashCode('a', 1, "blah"), testTable.hashCode());
}
public void testCellSet() {
assertEquals(ImmutableSet.of(Tables.immutableCell('a', 1, "blah")), testTable.cellSet());
}
public void testColumn() {
assertEquals(ImmutableMap.of(), testTable.column(0));
Reported by PMD.
Line: 44
assertEquals(ImmutableSet.of(Tables.immutableCell('a', 1, "blah")), testTable.cellSet());
}
public void testColumn() {
assertEquals(ImmutableMap.of(), testTable.column(0));
assertEquals(ImmutableMap.of('a', "blah"), testTable.column(1));
}
public void testColumnKeySet() {
Reported by PMD.
Line: 44
assertEquals(ImmutableSet.of(Tables.immutableCell('a', 1, "blah")), testTable.cellSet());
}
public void testColumn() {
assertEquals(ImmutableMap.of(), testTable.column(0));
assertEquals(ImmutableMap.of('a', "blah"), testTable.column(1));
}
public void testColumnKeySet() {
Reported by PMD.
Line: 49
assertEquals(ImmutableMap.of('a', "blah"), testTable.column(1));
}
public void testColumnKeySet() {
assertEquals(ImmutableSet.of(1), testTable.columnKeySet());
}
public void testColumnMap() {
assertEquals(ImmutableMap.of(1, ImmutableMap.of('a', "blah")), testTable.columnMap());
Reported by PMD.
Line: 53
assertEquals(ImmutableSet.of(1), testTable.columnKeySet());
}
public void testColumnMap() {
assertEquals(ImmutableMap.of(1, ImmutableMap.of('a', "blah")), testTable.columnMap());
}
public void testRow() {
assertEquals(ImmutableMap.of(), testTable.row('A'));
Reported by PMD.
Line: 57
assertEquals(ImmutableMap.of(1, ImmutableMap.of('a', "blah")), testTable.columnMap());
}
public void testRow() {
assertEquals(ImmutableMap.of(), testTable.row('A'));
assertEquals(ImmutableMap.of(1, "blah"), testTable.row('a'));
}
public void testRowKeySet() {
Reported by PMD.
android/guava-tests/benchmark/com/google/common/util/concurrent/MonitorBasedPriorityBlockingQueue.java
30 issues
Line: 417
*/
@Override
public int drainTo(Collection<? super E> c) {
if (c == null) throw new NullPointerException();
if (c == this) throw new IllegalArgumentException();
final Monitor monitor = this.monitor;
monitor.enter();
try {
int n = 0;
Reported by PMD.
Line: 442
*/
@Override
public int drainTo(Collection<? super E> c, int maxElements) {
if (c == null) throw new NullPointerException();
if (c == this) throw new IllegalArgumentException();
if (maxElements <= 0) return 0;
final Monitor monitor = this.monitor;
monitor.enter();
try {
Reported by PMD.
Line: 81
*/
@CanIgnoreReturnValue // TODO(cpovirk): Consider being more strict.
public class MonitorBasedPriorityBlockingQueue<E> extends AbstractQueue<E>
implements BlockingQueue<E> {
// Based on revision 1.55 of PriorityBlockingQueue by Doug Lea, from
// http://gee.cs.oswego.edu/cgi-bin/viewcvs.cgi/jsr166/src/main/java/util/concurrent/
private static final long serialVersionUID = 5595510919245408276L;
Reported by PMD.
Line: 88
private static final long serialVersionUID = 5595510919245408276L;
final PriorityQueue<E> q;
final Monitor monitor = new Monitor(true);
private final Monitor.Guard notEmpty =
new Monitor.Guard(monitor) {
@Override
public boolean isSatisfied() {
Reported by PMD.
Line: 89
private static final long serialVersionUID = 5595510919245408276L;
final PriorityQueue<E> q;
final Monitor monitor = new Monitor(true);
private final Monitor.Guard notEmpty =
new Monitor.Guard(monitor) {
@Override
public boolean isSatisfied() {
return !q.isEmpty();
Reported by PMD.
Line: 90
final PriorityQueue<E> q;
final Monitor monitor = new Monitor(true);
private final Monitor.Guard notEmpty =
new Monitor.Guard(monitor) {
@Override
public boolean isSatisfied() {
return !q.isEmpty();
}
Reported by PMD.
Line: 172
@Override
public boolean offer(E e) {
final Monitor monitor = this.monitor;
monitor.enter();
try {
boolean ok = q.offer(e);
if (!ok) {
throw new AssertionError();
}
Reported by PMD.
Line: 219
@Override
public E poll() {
final Monitor monitor = this.monitor;
monitor.enter();
try {
return q.poll();
} finally {
monitor.leave();
}
Reported by PMD.
Line: 230
@Override
public E poll(long timeout, TimeUnit unit) throws InterruptedException {
final Monitor monitor = this.monitor;
if (monitor.enterWhen(notEmpty, timeout, unit)) {
try {
return q.poll();
} finally {
monitor.leave();
}
Reported by PMD.
Line: 244
@Override
public E take() throws InterruptedException {
final Monitor monitor = this.monitor;
monitor.enterWhen(notEmpty);
try {
return q.poll();
} finally {
monitor.leave();
}
Reported by PMD.
android/guava-tests/test/com/google/common/collect/ForwardingSortedMapImplementsMapTest.java
30 issues
Line: 34
public class ForwardingSortedMapImplementsMapTest extends SortedMapInterfaceTest<String, Integer> {
private static class SimpleForwardingSortedMap<K, V> extends ForwardingSortedMap<K, V> {
final SortedMap<K, V> delegate;
SimpleForwardingSortedMap(SortedMap<K, V> delegate) {
this.delegate = delegate;
}
Reported by PMD.
Line: 34
public class ForwardingSortedMapImplementsMapTest extends SortedMapInterfaceTest<String, Integer> {
private static class SimpleForwardingSortedMap<K, V> extends ForwardingSortedMap<K, V> {
final SortedMap<K, V> delegate;
SimpleForwardingSortedMap(SortedMap<K, V> delegate) {
this.delegate = delegate;
}
Reported by PMD.
Line: 53
@Override
protected SortedMap<String, Integer> makeEmptyMap() {
return new SimpleForwardingSortedMap<>(
new TreeMap<String, Integer>(Ordering.natural().nullsFirst()));
}
@Override
protected SortedMap<String, Integer> makePopulatedMap() {
final SortedMap<String, Integer> sortedMap = makeEmptyMap();
Reported by PMD.
Line: 59
@Override
protected SortedMap<String, Integer> makePopulatedMap() {
final SortedMap<String, Integer> sortedMap = makeEmptyMap();
sortedMap.put("one", 1);
sortedMap.put("two", 2);
sortedMap.put("three", 3);
return sortedMap;
}
Reported by PMD.
Line: 60
protected SortedMap<String, Integer> makePopulatedMap() {
final SortedMap<String, Integer> sortedMap = makeEmptyMap();
sortedMap.put("one", 1);
sortedMap.put("two", 2);
sortedMap.put("three", 3);
return sortedMap;
}
@Override
Reported by PMD.
Line: 61
final SortedMap<String, Integer> sortedMap = makeEmptyMap();
sortedMap.put("one", 1);
sortedMap.put("two", 2);
sortedMap.put("three", 3);
return sortedMap;
}
@Override
protected String getKeyNotInPopulatedMap() throws UnsupportedOperationException {
Reported by PMD.
Line: 66
}
@Override
protected String getKeyNotInPopulatedMap() throws UnsupportedOperationException {
return "minus one";
}
@Override
protected Integer getValueNotInPopulatedMap() throws UnsupportedOperationException {
Reported by PMD.
Line: 71
}
@Override
protected Integer getValueNotInPopulatedMap() throws UnsupportedOperationException {
return -1;
}
@Override
public void testContainsKey() {
Reported by PMD.
Line: 75
return -1;
}
@Override
public void testContainsKey() {
try {
super.testContainsKey();
} catch (ClassCastException tolerated) {
}
Reported by PMD.
Line: 79
public void testContainsKey() {
try {
super.testContainsKey();
} catch (ClassCastException tolerated) {
}
}
@Override
public void testEntrySetContainsEntryIncompatibleKey() {
Reported by PMD.
guava/src/com/google/common/base/Predicates.java
30 issues
Line: 15
* the License.
*/
package com.google.common.base;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
Reported by PMD.
Line: 44
*/
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public final class Predicates {
private Predicates() {}
// TODO(kevinb): considering having these implement a VisitablePredicate
// interface which specifies an accept(PredicateVisitor) method.
Reported by PMD.
Line: 53
/** Returns a predicate that always evaluates to {@code true}. */
@GwtCompatible(serializable = true)
public static <T extends @Nullable Object> Predicate<T> alwaysTrue() {
return ObjectPredicate.ALWAYS_TRUE.withNarrowedType();
}
/** Returns a predicate that always evaluates to {@code false}. */
@GwtCompatible(serializable = true)
public static <T extends @Nullable Object> Predicate<T> alwaysFalse() {
Reported by PMD.
Line: 59
/** Returns a predicate that always evaluates to {@code false}. */
@GwtCompatible(serializable = true)
public static <T extends @Nullable Object> Predicate<T> alwaysFalse() {
return ObjectPredicate.ALWAYS_FALSE.withNarrowedType();
}
/**
* Returns a predicate that evaluates to {@code true} if the object reference being tested is
* null.
Reported by PMD.
Line: 68
*/
@GwtCompatible(serializable = true)
public static <T extends @Nullable Object> Predicate<T> isNull() {
return ObjectPredicate.IS_NULL.withNarrowedType();
}
/**
* Returns a predicate that evaluates to {@code true} if the object reference being tested is not
* null.
Reported by PMD.
Line: 77
*/
@GwtCompatible(serializable = true)
public static <T extends @Nullable Object> Predicate<T> notNull() {
return ObjectPredicate.NOT_NULL.withNarrowedType();
}
/**
* Returns a predicate that evaluates to {@code true} if the given predicate evaluates to {@code
* false}.
Reported by PMD.
Line: 317
/** @see Predicates#not(Predicate) */
private static class NotPredicate<T extends @Nullable Object>
implements Predicate<T>, Serializable {
final Predicate<T> predicate;
NotPredicate(Predicate<T> predicate) {
this.predicate = checkNotNull(predicate);
}
Reported by PMD.
Line: 353
/** @see Predicates#and(Iterable) */
private static class AndPredicate<T extends @Nullable Object>
implements Predicate<T>, Serializable {
private final List<? extends Predicate<? super T>> components;
private AndPredicate(List<? extends Predicate<? super T>> components) {
this.components = components;
}
Reported by PMD.
Line: 362
@Override
public boolean apply(@ParametricNullness T t) {
// Avoid using the Iterator to avoid generating garbage (issue 820).
for (int i = 0; i < components.size(); i++) {
if (!components.get(i).apply(t)) {
return false;
}
}
return true;
Reported by PMD.
Line: 363
public boolean apply(@ParametricNullness T t) {
// Avoid using the Iterator to avoid generating garbage (issue 820).
for (int i = 0; i < components.size(); i++) {
if (!components.get(i).apply(t)) {
return false;
}
}
return true;
}
Reported by PMD.
guava/src/com/google/common/collect/SortedMultisets.java
29 issues
Line: 48
@SuppressWarnings("JdkObsolete") // TODO(b/6160855): Switch GWT emulations to NavigableSet.
static class ElementSet<E extends @Nullable Object> extends Multisets.ElementSet<E>
implements SortedSet<E> {
@Weak private final SortedMultiset<E> multiset;
ElementSet(SortedMultiset<E> multiset) {
this.multiset = multiset;
}
Reported by PMD.
Line: 48
@SuppressWarnings("JdkObsolete") // TODO(b/6160855): Switch GWT emulations to NavigableSet.
static class ElementSet<E extends @Nullable Object> extends Multisets.ElementSet<E>
implements SortedSet<E> {
@Weak private final SortedMultiset<E> multiset;
ElementSet(SortedMultiset<E> multiset) {
this.multiset = multiset;
}
Reported by PMD.
Line: 61
@Override
public Iterator<E> iterator() {
return Multisets.elementIterator(multiset().entrySet().iterator());
}
@Override
public Comparator<? super E> comparator() {
return multiset().comparator();
Reported by PMD.
Line: 61
@Override
public Iterator<E> iterator() {
return Multisets.elementIterator(multiset().entrySet().iterator());
}
@Override
public Comparator<? super E> comparator() {
return multiset().comparator();
Reported by PMD.
Line: 66
@Override
public Comparator<? super E> comparator() {
return multiset().comparator();
}
@Override
public SortedSet<E> subSet(@ParametricNullness E fromElement, @ParametricNullness E toElement) {
return multiset().subMultiset(fromElement, CLOSED, toElement, OPEN).elementSet();
Reported by PMD.
Line: 71
@Override
public SortedSet<E> subSet(@ParametricNullness E fromElement, @ParametricNullness E toElement) {
return multiset().subMultiset(fromElement, CLOSED, toElement, OPEN).elementSet();
}
@Override
public SortedSet<E> headSet(@ParametricNullness E toElement) {
return multiset().headMultiset(toElement, OPEN).elementSet();
Reported by PMD.
Line: 71
@Override
public SortedSet<E> subSet(@ParametricNullness E fromElement, @ParametricNullness E toElement) {
return multiset().subMultiset(fromElement, CLOSED, toElement, OPEN).elementSet();
}
@Override
public SortedSet<E> headSet(@ParametricNullness E toElement) {
return multiset().headMultiset(toElement, OPEN).elementSet();
Reported by PMD.
Line: 76
@Override
public SortedSet<E> headSet(@ParametricNullness E toElement) {
return multiset().headMultiset(toElement, OPEN).elementSet();
}
@Override
public SortedSet<E> tailSet(@ParametricNullness E fromElement) {
return multiset().tailMultiset(fromElement, CLOSED).elementSet();
Reported by PMD.
Line: 76
@Override
public SortedSet<E> headSet(@ParametricNullness E toElement) {
return multiset().headMultiset(toElement, OPEN).elementSet();
}
@Override
public SortedSet<E> tailSet(@ParametricNullness E fromElement) {
return multiset().tailMultiset(fromElement, CLOSED).elementSet();
Reported by PMD.
Line: 81
@Override
public SortedSet<E> tailSet(@ParametricNullness E fromElement) {
return multiset().tailMultiset(fromElement, CLOSED).elementSet();
}
@Override
@ParametricNullness
public E first() {
Reported by PMD.
guava/src/com/google/common/base/Preconditions.java
29 issues
Line: 889
@CanIgnoreReturnValue
public static <T> T checkNotNull(@CheckForNull T reference) {
if (reference == null) {
throw new NullPointerException();
}
return reference;
}
/**
Reported by PMD.
Line: 907
@CanIgnoreReturnValue
public static <T> T checkNotNull(@CheckForNull T reference, @CheckForNull Object errorMessage) {
if (reference == null) {
throw new NullPointerException(String.valueOf(errorMessage));
}
return reference;
}
/**
Reported by PMD.
Line: 933
String errorMessageTemplate,
@CheckForNull @Nullable Object... errorMessageArgs) {
if (reference == null) {
throw new NullPointerException(lenientFormat(errorMessageTemplate, errorMessageArgs));
}
return reference;
}
/**
Reported by PMD.
Line: 948
@CanIgnoreReturnValue
public static <T> T checkNotNull(@CheckForNull T obj, String errorMessageTemplate, char p1) {
if (obj == null) {
throw new NullPointerException(lenientFormat(errorMessageTemplate, p1));
}
return obj;
}
/**
Reported by PMD.
Line: 963
@CanIgnoreReturnValue
public static <T> T checkNotNull(@CheckForNull T obj, String errorMessageTemplate, int p1) {
if (obj == null) {
throw new NullPointerException(lenientFormat(errorMessageTemplate, p1));
}
return obj;
}
/**
Reported by PMD.
Line: 978
@CanIgnoreReturnValue
public static <T> T checkNotNull(@CheckForNull T obj, String errorMessageTemplate, long p1) {
if (obj == null) {
throw new NullPointerException(lenientFormat(errorMessageTemplate, p1));
}
return obj;
}
/**
Reported by PMD.
Line: 994
public static <T> T checkNotNull(
@CheckForNull T obj, String errorMessageTemplate, @CheckForNull Object p1) {
if (obj == null) {
throw new NullPointerException(lenientFormat(errorMessageTemplate, p1));
}
return obj;
}
/**
Reported by PMD.
Line: 1010
public static <T> T checkNotNull(
@CheckForNull T obj, String errorMessageTemplate, char p1, char p2) {
if (obj == null) {
throw new NullPointerException(lenientFormat(errorMessageTemplate, p1, p2));
}
return obj;
}
/**
Reported by PMD.
Line: 1026
public static <T> T checkNotNull(
@CheckForNull T obj, String errorMessageTemplate, char p1, int p2) {
if (obj == null) {
throw new NullPointerException(lenientFormat(errorMessageTemplate, p1, p2));
}
return obj;
}
/**
Reported by PMD.
Line: 1042
public static <T> T checkNotNull(
@CheckForNull T obj, String errorMessageTemplate, char p1, long p2) {
if (obj == null) {
throw new NullPointerException(lenientFormat(errorMessageTemplate, p1, p2));
}
return obj;
}
/**
Reported by PMD.
guava/src/com/google/common/collect/ImmutableSetMultimap.java
29 issues
Line: 61
*/
@GwtCompatible(serializable = true, emulated = true)
@ElementTypesAreNonnullByDefault
public class ImmutableSetMultimap<K, V> extends ImmutableMultimap<K, V>
implements SetMultimap<K, V> {
/**
* Returns a {@link Collector} that accumulates elements into an {@code ImmutableSetMultimap}
* whose keys and values are the result of applying the provided mapping functions to the input
* elements.
Reported by PMD.
Line: 62
@GwtCompatible(serializable = true, emulated = true)
@ElementTypesAreNonnullByDefault
public class ImmutableSetMultimap<K, V> extends ImmutableMultimap<K, V>
implements SetMultimap<K, V> {
/**
* Returns a {@link Collector} that accumulates elements into an {@code ImmutableSetMultimap}
* whose keys and values are the result of applying the provided mapping functions to the input
* elements.
*
Reported by PMD.
Line: 204
* Returns an immutable multimap containing the given entries, in order. Repeated occurrences of
* an entry (according to {@link Object#equals}) after the first are ignored.
*/
public static <K, V> ImmutableSetMultimap<K, V> of(
K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5) {
ImmutableSetMultimap.Builder<K, V> builder = ImmutableSetMultimap.builder();
builder.put(k1, v1);
builder.put(k2, v2);
builder.put(k3, v3);
Reported by PMD.
Line: 241
*
* @since 2.0
*/
public static final class Builder<K, V> extends ImmutableMultimap.Builder<K, V> {
/**
* Creates a new builder. The returned builder is equivalent to the builder generated by {@link
* ImmutableSetMultimap#builder}.
*/
public Builder() {
Reported by PMD.
Line: 305
@Override
public Builder<K, V> putAll(Multimap<? extends K, ? extends V> multimap) {
for (Entry<? extends K, ? extends Collection<? extends V>> entry :
multimap.asMap().entrySet()) {
putAll(entry.getKey(), entry.getValue());
}
return this;
}
Reported by PMD.
Line: 353
public ImmutableSetMultimap<K, V> build() {
Collection<Map.Entry<K, Collection<V>>> mapEntries = builderMap.entrySet();
if (keyComparator != null) {
mapEntries = Ordering.from(keyComparator).<K>onKeys().immutableSortedCopy(mapEntries);
}
return fromMapEntries(mapEntries, valueComparator);
}
}
Reported by PMD.
Line: 353
public ImmutableSetMultimap<K, V> build() {
Collection<Map.Entry<K, Collection<V>>> mapEntries = builderMap.entrySet();
if (keyComparator != null) {
mapEntries = Ordering.from(keyComparator).<K>onKeys().immutableSortedCopy(mapEntries);
}
return fromMapEntries(mapEntries, valueComparator);
}
}
Reported by PMD.
Line: 387
if (multimap instanceof ImmutableSetMultimap) {
@SuppressWarnings("unchecked") // safe since multimap is not writable
ImmutableSetMultimap<K, V> kvMultimap = (ImmutableSetMultimap<K, V>) multimap;
if (!kvMultimap.isPartialView()) {
return kvMultimap;
}
}
return fromMapEntries(multimap.asMap().entrySet(), valueComparator);
Reported by PMD.
Line: 392
}
}
return fromMapEntries(multimap.asMap().entrySet(), valueComparator);
}
/**
* Returns an immutable multimap containing the specified entries. The returned multimap iterates
* over keys in the order they were first encountered in the input, and the values for each key
Reported by PMD.
Line: 425
K key = entry.getKey();
Collection<? extends V> values = entry.getValue();
ImmutableSet<V> set = valueSet(valueComparator, values);
if (!set.isEmpty()) {
builder.put(key, set);
size += set.size();
}
}
Reported by PMD.