The following issues were found
guava-tests/test/com/google/common/reflect/TypeVisitorTest.java
9 issues
Line: 35
*/
public class TypeVisitorTest extends TestCase {
public void testVisitNull() {
new BaseTypeVisitor()
.visit(((ParameterizedType) ArrayList.class.getGenericSuperclass()).getOwnerType());
}
public void testVisitClass() {
Reported by PMD.
Line: 35
*/
public class TypeVisitorTest extends TestCase {
public void testVisitNull() {
new BaseTypeVisitor()
.visit(((ParameterizedType) ArrayList.class.getGenericSuperclass()).getOwnerType());
}
public void testVisitClass() {
Reported by PMD.
Line: 37
public void testVisitNull() {
new BaseTypeVisitor()
.visit(((ParameterizedType) ArrayList.class.getGenericSuperclass()).getOwnerType());
}
public void testVisitClass() {
assertVisited(String.class);
new BaseTypeVisitor() {
Reported by PMD.
Line: 40
.visit(((ParameterizedType) ArrayList.class.getGenericSuperclass()).getOwnerType());
}
public void testVisitClass() {
assertVisited(String.class);
new BaseTypeVisitor() {
@Override
void visitClass(Class<?> t) {}
}.visit(String.class);
Reported by PMD.
Line: 48
}.visit(String.class);
}
public <T> void testVisitTypeVariable() {
Type type = new TypeCapture<T>() {}.capture();
assertVisited(type);
new BaseTypeVisitor() {
@Override
void visitTypeVariable(TypeVariable<?> t) {}
Reported by PMD.
Line: 57
}.visit(type);
}
public void testVisitWildcardType() {
WildcardType type = Types.subtypeOf(String.class);
assertVisited(type);
new BaseTypeVisitor() {
@Override
void visitWildcardType(WildcardType t) {}
Reported by PMD.
Line: 66
}.visit(type);
}
public <T> void testVisitGenericArrayType() {
Type type = new TypeCapture<T[]>() {}.capture();
assertVisited(type);
new BaseTypeVisitor() {
@Override
void visitGenericArrayType(GenericArrayType t) {}
Reported by PMD.
Line: 75
}.visit(type);
}
public <T> void testVisitParameterizedType() {
Type type = new TypeCapture<Iterable<T>>() {}.capture();
assertVisited(type);
new BaseTypeVisitor() {
@Override
void visitParameterizedType(ParameterizedType t) {}
Reported by PMD.
Line: 84
}.visit(type);
}
public <E extends Enum<E>> void testVisitRecursiveTypeBounds() {
Type type = new TypeCapture<EnumSet<E>>() {}.capture();
assertVisited(type);
new BaseTypeVisitor() {
@Override
void visitParameterizedType(ParameterizedType t) {
Reported by PMD.
guava/src/com/google/common/collect/RegularImmutableSet.java
9 issues
Line: 40
new RegularImmutableSet<>(EMPTY_ARRAY, 0, EMPTY_ARRAY, 0);
private final transient Object[] elements;
private final transient int hashCode;
// the same values as `elements` in hashed positions (plus nulls)
@VisibleForTesting final transient @Nullable Object[] table;
// 'and' with an int to get a valid table index.
private final transient int mask;
Reported by PMD.
Line: 46
// 'and' with an int to get a valid table index.
private final transient int mask;
RegularImmutableSet(Object[] elements, int hashCode, @Nullable Object[] table, int mask) {
this.elements = elements;
this.hashCode = hashCode;
this.table = table;
this.mask = mask;
}
Reported by PMD.
Line: 46
// 'and' with an int to get a valid table index.
private final transient int mask;
RegularImmutableSet(Object[] elements, int hashCode, @Nullable Object[] table, int mask) {
this.elements = elements;
this.hashCode = hashCode;
this.table = table;
this.mask = mask;
}
Reported by PMD.
Line: 60
return false;
}
for (int i = Hashing.smearedHash(target); ; i++) {
i &= mask;
Object candidate = table[i];
if (candidate == null) {
return false;
} else if (candidate.equals(target)) {
return true;
Reported by PMD.
Line: 64
Object candidate = table[i];
if (candidate == null) {
return false;
} else if (candidate.equals(target)) {
return true;
}
}
}
Reported by PMD.
Line: 87
@Override
Object[] internalArray() {
return elements;
}
@Override
int internalArrayStart() {
return 0;
Reported by PMD.
Line: 119
}
@Override
public int hashCode() {
return hashCode;
}
@Override
boolean isHashCodeFast() {
Reported by PMD.
Line: 59
if (target == null || table.length == 0) {
return false;
}
for (int i = Hashing.smearedHash(target); ; i++) {
i &= mask;
Object candidate = table[i];
if (candidate == null) {
return false;
} else if (candidate.equals(target)) {
Reported by PMD.
Line: 59
if (target == null || table.length == 0) {
return false;
}
for (int i = Hashing.smearedHash(target); ; i++) {
i &= mask;
Object candidate = table[i];
if (candidate == null) {
return false;
} else if (candidate.equals(target)) {
Reported by PMD.
guava/src/com/google/common/collect/IndexedImmutableSet.java
9 issues
Line: 29
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
abstract class IndexedImmutableSet<E> extends ImmutableSet<E> {
abstract E get(int index);
@Override
public UnmodifiableIterator<E> iterator() {
return asList().iterator();
Reported by PMD.
Line: 34
@Override
public UnmodifiableIterator<E> iterator() {
return asList().iterator();
}
@Override
public Spliterator<E> spliterator() {
return CollectSpliterators.indexed(size(), SPLITERATOR_CHARACTERISTICS, this::get);
Reported by PMD.
Line: 54
@Override
@GwtIncompatible
int copyIntoArray(@Nullable Object[] dst, int offset) {
return asList().copyIntoArray(dst, offset);
}
@Override
ImmutableList<E> createAsList() {
return new ImmutableAsList<E>() {
Reported by PMD.
Line: 62
return new ImmutableAsList<E>() {
@Override
public E get(int index) {
return IndexedImmutableSet.this.get(index);
}
@Override
boolean isPartialView() {
return IndexedImmutableSet.this.isPartialView();
Reported by PMD.
Line: 62
return new ImmutableAsList<E>() {
@Override
public E get(int index) {
return IndexedImmutableSet.this.get(index);
}
@Override
boolean isPartialView() {
return IndexedImmutableSet.this.isPartialView();
Reported by PMD.
Line: 67
@Override
boolean isPartialView() {
return IndexedImmutableSet.this.isPartialView();
}
@Override
public int size() {
return IndexedImmutableSet.this.size();
Reported by PMD.
Line: 67
@Override
boolean isPartialView() {
return IndexedImmutableSet.this.isPartialView();
}
@Override
public int size() {
return IndexedImmutableSet.this.size();
Reported by PMD.
Line: 72
@Override
public int size() {
return IndexedImmutableSet.this.size();
}
@Override
ImmutableCollection<E> delegateCollection() {
return IndexedImmutableSet.this;
Reported by PMD.
Line: 72
@Override
public int size() {
return IndexedImmutableSet.this.size();
}
@Override
ImmutableCollection<E> delegateCollection() {
return IndexedImmutableSet.this;
Reported by PMD.
guava/src/com/google/common/base/Ascii.java
9 issues
Line: 550
* truncationIndicator}
* @since 16.0
*/
public static String truncate(CharSequence seq, int maxLength, String truncationIndicator) {
checkNotNull(seq);
// length to truncate the sequence to, not including the truncation indicator
int truncationLength = maxLength - truncationIndicator.length();
Reported by PMD.
Line: 622
if (alphaIndex < 26 && alphaIndex == getAlphaIndex(c2)) {
continue;
}
return false;
}
return true;
}
/**
Reported by PMD.
Line: 412
for (int i = 0; i < length; i++) {
if (isUpperCase(string.charAt(i))) {
char[] chars = string.toCharArray();
for (; i < length; i++) {
char c = chars[i];
if (isUpperCase(c)) {
chars[i] = (char) (c ^ CASE_MASK);
}
}
Reported by PMD.
Line: 412
for (int i = 0; i < length; i++) {
if (isUpperCase(string.charAt(i))) {
char[] chars = string.toCharArray();
for (; i < length; i++) {
char c = chars[i];
if (isUpperCase(c)) {
chars[i] = (char) (c ^ CASE_MASK);
}
}
Reported by PMD.
Line: 460
for (int i = 0; i < length; i++) {
if (isLowerCase(string.charAt(i))) {
char[] chars = string.toCharArray();
for (; i < length; i++) {
char c = chars[i];
if (isLowerCase(c)) {
chars[i] = (char) (c ^ CASE_MASK);
}
}
Reported by PMD.
Line: 460
for (int i = 0; i < length; i++) {
if (isLowerCase(string.charAt(i))) {
char[] chars = string.toCharArray();
for (; i < length; i++) {
char c = chars[i];
if (isLowerCase(c)) {
chars[i] = (char) (c ^ CASE_MASK);
}
}
Reported by PMD.
Line: 566
if (seq.length() <= maxLength) {
String string = seq.toString();
if (string.length() <= maxLength) {
return string;
}
// if the length of the toString() result was > maxLength for some reason, truncate that
seq = string;
}
Reported by PMD.
Line: 604
public static boolean equalsIgnoreCase(CharSequence s1, CharSequence s2) {
// Calling length() is the null pointer check (so do it before we can exit early).
int length = s1.length();
if (s1 == s2) {
return true;
}
if (length != s2.length()) {
return false;
}
Reported by PMD.
Line: 603
*/
public static boolean equalsIgnoreCase(CharSequence s1, CharSequence s2) {
// Calling length() is the null pointer check (so do it before we can exit early).
int length = s1.length();
if (s1 == s2) {
return true;
}
if (length != s2.length()) {
return false;
Reported by PMD.
guava/src/com/google/common/base/SmallCharMatcher.java
9 issues
Line: 32
@ElementTypesAreNonnullByDefault
final class SmallCharMatcher extends NamedFastMatcher {
static final int MAX_SIZE = 1023;
private final char[] table;
private final boolean containsZero;
private final long filter;
private SmallCharMatcher(char[] table, long filter, boolean containsZero, String description) {
super(description);
Reported by PMD.
Line: 33
final class SmallCharMatcher extends NamedFastMatcher {
static final int MAX_SIZE = 1023;
private final char[] table;
private final boolean containsZero;
private final long filter;
private SmallCharMatcher(char[] table, long filter, boolean containsZero, String description) {
super(description);
this.table = table;
Reported by PMD.
Line: 34
static final int MAX_SIZE = 1023;
private final char[] table;
private final boolean containsZero;
private final long filter;
private SmallCharMatcher(char[] table, long filter, boolean containsZero, String description) {
super(description);
this.table = table;
this.filter = filter;
Reported by PMD.
Line: 75
*/
@VisibleForTesting
static int chooseTableSize(int setSize) {
if (setSize == 1) {
return 2;
}
// Correct the size for open addressing to match desired load factor.
// Round up to the next highest power of 2.
int tableSize = Integer.highestOneBit(setSize - 1) << 1;
Reported by PMD.
Line: 94
boolean containsZero = chars.get(0);
// Compute the hash table.
char[] table = new char[chooseTableSize(size)];
int mask = table.length - 1;
for (int c = chars.nextSetBit(0); c != -1; c = chars.nextSetBit(c + 1)) {
// Compute the filter at the same time.
filter |= 1L << c;
int index = smear(c) & mask;
while (true) {
Reported by PMD.
Line: 98
for (int c = chars.nextSetBit(0); c != -1; c = chars.nextSetBit(c + 1)) {
// Compute the filter at the same time.
filter |= 1L << c;
int index = smear(c) & mask;
while (true) {
// Check for empty.
if (table[index] == 0) {
table[index] = (char) c;
break;
Reported by PMD.
Line: 98
for (int c = chars.nextSetBit(0); c != -1; c = chars.nextSetBit(c + 1)) {
// Compute the filter at the same time.
filter |= 1L << c;
int index = smear(c) & mask;
while (true) {
// Check for empty.
if (table[index] == 0) {
table[index] = (char) c;
break;
Reported by PMD.
Line: 106
break;
}
// Linear probing.
index = (index + 1) & mask;
}
}
return new SmallCharMatcher(table, filter, containsZero, description);
}
Reported by PMD.
Line: 106
break;
}
// Linear probing.
index = (index + 1) & mask;
}
}
return new SmallCharMatcher(table, filter, containsZero, description);
}
Reported by PMD.
guava/src/com/google/common/collect/MapMaker.java
9 issues
Line: 97
static final int UNSET_INT = -1;
// TODO(kevinb): dispense with this after benchmarking
boolean useCustomMap;
int initialCapacity = UNSET_INT;
int concurrencyLevel = UNSET_INT;
@CheckForNull Strength keyStrength;
Reported by PMD.
Line: 99
// TODO(kevinb): dispense with this after benchmarking
boolean useCustomMap;
int initialCapacity = UNSET_INT;
int concurrencyLevel = UNSET_INT;
@CheckForNull Strength keyStrength;
@CheckForNull Strength valueStrength;
Reported by PMD.
Line: 99
// TODO(kevinb): dispense with this after benchmarking
boolean useCustomMap;
int initialCapacity = UNSET_INT;
int concurrencyLevel = UNSET_INT;
@CheckForNull Strength keyStrength;
@CheckForNull Strength valueStrength;
Reported by PMD.
Line: 100
boolean useCustomMap;
int initialCapacity = UNSET_INT;
int concurrencyLevel = UNSET_INT;
@CheckForNull Strength keyStrength;
@CheckForNull Strength valueStrength;
@CheckForNull Equivalence<Object> keyEquivalence;
Reported by PMD.
Line: 100
boolean useCustomMap;
int initialCapacity = UNSET_INT;
int concurrencyLevel = UNSET_INT;
@CheckForNull Strength keyStrength;
@CheckForNull Strength valueStrength;
@CheckForNull Equivalence<Object> keyEquivalence;
Reported by PMD.
Line: 105
@CheckForNull Strength keyStrength;
@CheckForNull Strength valueStrength;
@CheckForNull Equivalence<Object> keyEquivalence;
/**
* Constructs a new {@code MapMaker} instance with default settings, including strong keys, strong
* values, and no automatic eviction of any kind.
*/
Reported by PMD.
Line: 105
@CheckForNull Strength keyStrength;
@CheckForNull Strength valueStrength;
@CheckForNull Equivalence<Object> keyEquivalence;
/**
* Constructs a new {@code MapMaker} instance with default settings, including strong keys, strong
* values, and no automatic eviction of any kind.
*/
Reported by PMD.
Line: 130
}
Equivalence<Object> getKeyEquivalence() {
return MoreObjects.firstNonNull(keyEquivalence, getKeyStrength().defaultEquivalence());
}
/**
* Sets the minimum total size for the internal hash tables. For example, if the initial capacity
* is {@code 60}, and the concurrency level is {@code 8}, then eight segments are created, each
Reported by PMD.
Line: 309
if (keyEquivalence != null) {
s.addValue("keyEquivalence");
}
return s.toString();
}
}
Reported by PMD.
guava/src/com/google/common/hash/LittleEndianByteArray.java
9 issues
Line: 191
}
});
} catch (java.security.PrivilegedActionException e) {
throw new RuntimeException("Could not initialize intrinsics", e.getCause());
}
}
static {
theUnsafe = getUnsafe();
Reported by PMD.
Line: 170
*/
private static sun.misc.Unsafe getUnsafe() {
try {
return sun.misc.Unsafe.getUnsafe();
} catch (SecurityException tryReflectionInstead) {
// We'll try reflection instead.
}
try {
return java.security.AccessController.doPrivileged(
Reported by PMD.
Line: 171
private static sun.misc.Unsafe getUnsafe() {
try {
return sun.misc.Unsafe.getUnsafe();
} catch (SecurityException tryReflectionInstead) {
// We'll try reflection instead.
}
try {
return java.security.AccessController.doPrivileged(
new java.security.PrivilegedExceptionAction<sun.misc.Unsafe>() {
Reported by PMD.
Line: 191
}
});
} catch (java.security.PrivilegedActionException e) {
throw new RuntimeException("Could not initialize intrinsics", e.getCause());
}
}
static {
theUnsafe = getUnsafe();
Reported by PMD.
Line: 200
BYTE_ARRAY_BASE_OFFSET = theUnsafe.arrayBaseOffset(byte[].class);
// sanity check - this should never fail
if (theUnsafe.arrayIndexScale(byte[].class) != 1) {
throw new AssertionError();
}
}
}
Reported by PMD.
Line: 253
? UnsafeByteArray.UNSAFE_LITTLE_ENDIAN
: UnsafeByteArray.UNSAFE_BIG_ENDIAN;
}
} catch (Throwable t) {
// ensure we really catch *everything*
}
byteArray = theGetter;
}
Reported by PMD.
Line: 253
? UnsafeByteArray.UNSAFE_LITTLE_ENDIAN
: UnsafeByteArray.UNSAFE_BIG_ENDIAN;
}
} catch (Throwable t) {
// ensure we really catch *everything*
}
byteArray = theGetter;
}
Reported by PMD.
Line: 19
import com.google.common.primitives.Longs;
import java.nio.ByteOrder;
import sun.misc.Unsafe;
/**
* Utility functions for loading and storing values from a byte array.
*
* @author Kevin Damm
Reported by PMD.
Line: 224
@Override
public void putLongLittleEndian(byte[] sink, int offset, long value) {
long mask = 0xFFL;
for (int i = 0; i < 8; mask <<= 8, i++) {
sink[offset + i] = (byte) ((value & mask) >> (i * 8));
}
}
};
Reported by PMD.
guava/src/com/google/common/collect/EnumBiMap.java
9 issues
Line: 43
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public final class EnumBiMap<K extends Enum<K>, V extends Enum<V>> extends AbstractBiMap<K, V> {
private transient Class<K> keyType;
private transient Class<V> valueType;
/**
* Returns a new, empty {@code EnumBiMap} using the specified key and value types.
*
Reported by PMD.
Line: 44
@ElementTypesAreNonnullByDefault
public final class EnumBiMap<K extends Enum<K>, V extends Enum<V>> extends AbstractBiMap<K, V> {
private transient Class<K> keyType;
private transient Class<V> valueType;
/**
* Returns a new, empty {@code EnumBiMap} using the specified key and value types.
*
* @param keyType the key type
Reported by PMD.
Line: 68
*/
public static <K extends Enum<K>, V extends Enum<V>> EnumBiMap<K, V> create(Map<K, V> map) {
EnumBiMap<K, V> bimap = create(inferKeyType(map), inferValueType(map));
bimap.putAll(map);
return bimap;
}
private EnumBiMap(Class<K> keyType, Class<V> valueType) {
super(new EnumMap<K, V>(keyType), new EnumMap<V, K>(valueType));
Reported by PMD.
Line: 86
return ((EnumHashBiMap<K, ?>) map).keyType();
}
checkArgument(!map.isEmpty());
return map.keySet().iterator().next().getDeclaringClass();
}
private static <V extends Enum<V>> Class<V> inferValueType(Map<?, V> map) {
if (map instanceof EnumBiMap) {
return ((EnumBiMap<?, V>) map).valueType;
Reported by PMD.
Line: 86
return ((EnumHashBiMap<K, ?>) map).keyType();
}
checkArgument(!map.isEmpty());
return map.keySet().iterator().next().getDeclaringClass();
}
private static <V extends Enum<V>> Class<V> inferValueType(Map<?, V> map) {
if (map instanceof EnumBiMap) {
return ((EnumBiMap<?, V>) map).valueType;
Reported by PMD.
Line: 86
return ((EnumHashBiMap<K, ?>) map).keyType();
}
checkArgument(!map.isEmpty());
return map.keySet().iterator().next().getDeclaringClass();
}
private static <V extends Enum<V>> Class<V> inferValueType(Map<?, V> map) {
if (map instanceof EnumBiMap) {
return ((EnumBiMap<?, V>) map).valueType;
Reported by PMD.
Line: 94
return ((EnumBiMap<?, V>) map).valueType;
}
checkArgument(!map.isEmpty());
return map.values().iterator().next().getDeclaringClass();
}
/** Returns the associated key type. */
public Class<K> keyType() {
return keyType;
Reported by PMD.
Line: 94
return ((EnumBiMap<?, V>) map).valueType;
}
checkArgument(!map.isEmpty());
return map.values().iterator().next().getDeclaringClass();
}
/** Returns the associated key type. */
public Class<K> keyType() {
return keyType;
Reported by PMD.
Line: 94
return ((EnumBiMap<?, V>) map).valueType;
}
checkArgument(!map.isEmpty());
return map.values().iterator().next().getDeclaringClass();
}
/** Returns the associated key type. */
public Class<K> keyType() {
return keyType;
Reported by PMD.
guava/src/com/google/common/collect/Serialization.java
9 issues
Line: 86
Map<K, V> map, ObjectInputStream stream, int size)
throws IOException, ClassNotFoundException {
for (int i = 0; i < size; i++) {
@SuppressWarnings("unchecked") // reading data stored by writeMap
K key = (K) stream.readObject();
@SuppressWarnings("unchecked") // reading data stored by writeMap
V value = (V) stream.readObject();
map.put(key, value);
}
Reported by PMD.
Line: 103
*/
static <E extends @Nullable Object> void writeMultiset(
Multiset<E> multiset, ObjectOutputStream stream) throws IOException {
int entryCount = multiset.entrySet().size();
stream.writeInt(entryCount);
for (Multiset.Entry<E> entry : multiset.entrySet()) {
stream.writeObject(entry.getElement());
stream.writeInt(entry.getCount());
}
Reported by PMD.
Line: 147
*/
static <K extends @Nullable Object, V extends @Nullable Object> void writeMultimap(
Multimap<K, V> multimap, ObjectOutputStream stream) throws IOException {
stream.writeInt(multimap.asMap().size());
for (Map.Entry<K, Collection<V>> entry : multimap.asMap().entrySet()) {
stream.writeObject(entry.getKey());
stream.writeInt(entry.getValue().size());
for (V value : entry.getValue()) {
stream.writeObject(value);
Reported by PMD.
Line: 148
static <K extends @Nullable Object, V extends @Nullable Object> void writeMultimap(
Multimap<K, V> multimap, ObjectOutputStream stream) throws IOException {
stream.writeInt(multimap.asMap().size());
for (Map.Entry<K, Collection<V>> entry : multimap.asMap().entrySet()) {
stream.writeObject(entry.getKey());
stream.writeInt(entry.getValue().size());
for (V value : entry.getValue()) {
stream.writeObject(value);
}
Reported by PMD.
Line: 150
stream.writeInt(multimap.asMap().size());
for (Map.Entry<K, Collection<V>> entry : multimap.asMap().entrySet()) {
stream.writeObject(entry.getKey());
stream.writeInt(entry.getValue().size());
for (V value : entry.getValue()) {
stream.writeObject(value);
}
}
}
Reported by PMD.
Line: 184
for (int j = 0; j < valueCount; j++) {
@SuppressWarnings("unchecked") // reading data stored by writeMultimap
V value = (V) stream.readObject();
values.add(value);
}
}
}
// Secret sauce for setting final fields; don't make it public.
Reported by PMD.
Line: 201
// Secret sauce for setting final fields; don't make it public.
static final class FieldSetter<T> {
private final Field field;
private FieldSetter(Field field) {
this.field = field;
field.setAccessible(true);
}
Reported by PMD.
Line: 179
for (int i = 0; i < distinctKeys; i++) {
@SuppressWarnings("unchecked") // reading data stored by writeMultimap
K key = (K) stream.readObject();
Collection<V> values = multimap.get(key);
int valueCount = stream.readInt();
for (int j = 0; j < valueCount; j++) {
@SuppressWarnings("unchecked") // reading data stored by writeMultimap
V value = (V) stream.readObject();
values.add(value);
Reported by PMD.
Line: 179
for (int i = 0; i < distinctKeys; i++) {
@SuppressWarnings("unchecked") // reading data stored by writeMultimap
K key = (K) stream.readObject();
Collection<V> values = multimap.get(key);
int valueCount = stream.readInt();
for (int j = 0; j < valueCount; j++) {
@SuppressWarnings("unchecked") // reading data stored by writeMultimap
V value = (V) stream.readObject();
values.add(value);
Reported by PMD.
guava/src/com/google/common/collect/AbstractSortedMultiset.java
9 issues
Line: 39
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
abstract class AbstractSortedMultiset<E extends @Nullable Object> extends AbstractMultiset<E>
implements SortedMultiset<E> {
@GwtTransient final Comparator<? super E> comparator;
// needed for serialization
@SuppressWarnings("unchecked")
AbstractSortedMultiset() {
Reported by PMD.
Line: 40
@ElementTypesAreNonnullByDefault
abstract class AbstractSortedMultiset<E extends @Nullable Object> extends AbstractMultiset<E>
implements SortedMultiset<E> {
@GwtTransient final Comparator<? super E> comparator;
// needed for serialization
@SuppressWarnings("unchecked")
AbstractSortedMultiset() {
this((Comparator) Ordering.natural());
Reported by PMD.
Line: 40
@ElementTypesAreNonnullByDefault
abstract class AbstractSortedMultiset<E extends @Nullable Object> extends AbstractMultiset<E>
implements SortedMultiset<E> {
@GwtTransient final Comparator<? super E> comparator;
// needed for serialization
@SuppressWarnings("unchecked")
AbstractSortedMultiset() {
this((Comparator) Ordering.natural());
Reported by PMD.
Line: 87
Iterator<Entry<E>> entryIterator = entryIterator();
if (entryIterator.hasNext()) {
Entry<E> result = entryIterator.next();
result = Multisets.immutableEntry(result.getElement(), result.getCount());
entryIterator.remove();
return result;
}
return null;
}
Reported by PMD.
Line: 87
Iterator<Entry<E>> entryIterator = entryIterator();
if (entryIterator.hasNext()) {
Entry<E> result = entryIterator.next();
result = Multisets.immutableEntry(result.getElement(), result.getCount());
entryIterator.remove();
return result;
}
return null;
}
Reported by PMD.
Line: 100
Iterator<Entry<E>> entryIterator = descendingEntryIterator();
if (entryIterator.hasNext()) {
Entry<E> result = entryIterator.next();
result = Multisets.immutableEntry(result.getElement(), result.getCount());
entryIterator.remove();
return result;
}
return null;
}
Reported by PMD.
Line: 100
Iterator<Entry<E>> entryIterator = descendingEntryIterator();
if (entryIterator.hasNext()) {
Entry<E> result = entryIterator.next();
result = Multisets.immutableEntry(result.getElement(), result.getCount());
entryIterator.remove();
return result;
}
return null;
}
Reported by PMD.
Line: 116
// These are checked elsewhere, but NullPointerTester wants them checked eagerly.
checkNotNull(fromBoundType);
checkNotNull(toBoundType);
return tailMultiset(fromElement, fromBoundType).headMultiset(toElement, toBoundType);
}
abstract Iterator<Entry<E>> descendingEntryIterator();
Iterator<E> descendingIterator() {
Reported by PMD.
Line: 125
return Multisets.iteratorImpl(descendingMultiset());
}
@CheckForNull private transient SortedMultiset<E> descendingMultiset;
@Override
public SortedMultiset<E> descendingMultiset() {
SortedMultiset<E> result = descendingMultiset;
return (result == null) ? descendingMultiset = createDescendingMultiset() : result;
Reported by PMD.