The following issues were found
android/guava-tests/test/com/google/common/collect/ImmutableRangeMapTest.java
104 issues
Line: 32
* @author Louis Wasserman
*/
@GwtIncompatible // NavigableMap
public class ImmutableRangeMapTest extends TestCase {
private static final ImmutableList<Range<Integer>> RANGES;
private static final int MIN_BOUND = 0;
private static final int MAX_BOUND = 10;
static {
Reported by PMD.
Line: 66
RANGES = builder.build();
}
public void testBuilderRejectsEmptyRanges() {
for (int i = MIN_BOUND; i <= MAX_BOUND; i++) {
ImmutableRangeMap.Builder<Integer, Integer> builder = ImmutableRangeMap.builder();
try {
builder.put(Range.closedOpen(i, i), 1);
fail("Expected IllegalArgumentException");
Reported by PMD.
Line: 71
ImmutableRangeMap.Builder<Integer, Integer> builder = ImmutableRangeMap.builder();
try {
builder.put(Range.closedOpen(i, i), 1);
fail("Expected IllegalArgumentException");
} catch (IllegalArgumentException expected) {
// success
}
try {
builder.put(Range.openClosed(i, i), 1);
Reported by PMD.
Line: 77
}
try {
builder.put(Range.openClosed(i, i), 1);
fail("Expected IllegalArgumentException");
} catch (IllegalArgumentException expected) {
}
}
}
Reported by PMD.
Line: 83
}
}
public void testOverlapRejection() {
for (Range<Integer> range1 : RANGES) {
for (Range<Integer> range2 : RANGES) {
boolean expectRejection =
range1.isConnected(range2) && !range1.intersection(range2).isEmpty();
ImmutableRangeMap.Builder<Integer, Integer> builder = ImmutableRangeMap.builder();
Reported by PMD.
Line: 83
}
}
public void testOverlapRejection() {
for (Range<Integer> range1 : RANGES) {
for (Range<Integer> range2 : RANGES) {
boolean expectRejection =
range1.isConnected(range2) && !range1.intersection(range2).isEmpty();
ImmutableRangeMap.Builder<Integer, Integer> builder = ImmutableRangeMap.builder();
Reported by PMD.
Line: 87
for (Range<Integer> range1 : RANGES) {
for (Range<Integer> range2 : RANGES) {
boolean expectRejection =
range1.isConnected(range2) && !range1.intersection(range2).isEmpty();
ImmutableRangeMap.Builder<Integer, Integer> builder = ImmutableRangeMap.builder();
builder.put(range1, 1).put(range2, 2);
try {
ImmutableRangeMap<Integer, Integer> unused = builder.build();
assertFalse(expectRejection);
Reported by PMD.
Line: 89
boolean expectRejection =
range1.isConnected(range2) && !range1.intersection(range2).isEmpty();
ImmutableRangeMap.Builder<Integer, Integer> builder = ImmutableRangeMap.builder();
builder.put(range1, 1).put(range2, 2);
try {
ImmutableRangeMap<Integer, Integer> unused = builder.build();
assertFalse(expectRejection);
} catch (IllegalArgumentException e) {
assertTrue(expectRejection);
Reported by PMD.
Line: 91
ImmutableRangeMap.Builder<Integer, Integer> builder = ImmutableRangeMap.builder();
builder.put(range1, 1).put(range2, 2);
try {
ImmutableRangeMap<Integer, Integer> unused = builder.build();
assertFalse(expectRejection);
} catch (IllegalArgumentException e) {
assertTrue(expectRejection);
}
}
Reported by PMD.
Line: 92
builder.put(range1, 1).put(range2, 2);
try {
ImmutableRangeMap<Integer, Integer> unused = builder.build();
assertFalse(expectRejection);
} catch (IllegalArgumentException e) {
assertTrue(expectRejection);
}
}
}
Reported by PMD.
android/guava-tests/test/com/google/common/reflect/MutableTypeToInstanceMapTest.java
104 issues
Line: 85
public void testPutThrows() {
try {
map.put(TypeToken.of(Integer.class), new Integer(5));
fail();
} catch (UnsupportedOperationException expected) {
}
}
Reported by PMD.
Line: 93
public void testPutAllThrows() {
try {
map.putAll(ImmutableMap.of(TypeToken.of(Integer.class), new Integer(5)));
fail();
} catch (UnsupportedOperationException expected) {
}
}
Reported by PMD.
Line: 137
}
public void testPutAndGetInstance() {
assertNull(map.putInstance(Integer.class, new Integer(5)));
Integer oldValue = map.putInstance(Integer.class, new Integer(7));
assertEquals(5, (int) oldValue);
Integer newValue = map.getInstance(Integer.class);
Reported by PMD.
Line: 139
public void testPutAndGetInstance() {
assertNull(map.putInstance(Integer.class, new Integer(5)));
Integer oldValue = map.putInstance(Integer.class, new Integer(7));
assertEquals(5, (int) oldValue);
Integer newValue = map.getInstance(Integer.class);
assertEquals(7, (int) newValue);
assertEquals(7, (int) map.getInstance(TypeToken.of(Integer.class)));
Reported by PMD.
Line: 151
public void testNull() {
try {
map.putInstance((TypeToken) null, new Integer(1));
fail();
} catch (NullPointerException expected) {
}
map.putInstance(Integer.class, null);
assertTrue(map.containsKey(TypeToken.of(Integer.class)));
Reported by PMD.
Line: 40
*
* @author Ben Yu
*/
public class MutableTypeToInstanceMapTest extends TestCase {
@AndroidIncompatible // problem with suite builders on Android
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTestSuite(MutableTypeToInstanceMapTest.class);
Reported by PMD.
Line: 42
*/
public class MutableTypeToInstanceMapTest extends TestCase {
@AndroidIncompatible // problem with suite builders on Android
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTestSuite(MutableTypeToInstanceMapTest.class);
suite.addTest(
Reported by PMD.
Line: 53
// Other tests will verify what real, warning-free usage looks like
// but here we have to do some serious fudging
@Override
@SuppressWarnings("unchecked")
public Map<TypeToken, Object> create(Object... elements) {
MutableTypeToInstanceMap<Object> map = new MutableTypeToInstanceMap<>();
for (Object object : elements) {
Entry<TypeToken, Object> entry = (Entry<TypeToken, Object>) object;
map.putInstance(entry.getKey(), entry.getValue());
Reported by PMD.
Line: 58
MutableTypeToInstanceMap<Object> map = new MutableTypeToInstanceMap<>();
for (Object object : elements) {
Entry<TypeToken, Object> entry = (Entry<TypeToken, Object>) object;
map.putInstance(entry.getKey(), entry.getValue());
}
return (Map) map;
}
})
.named("MutableTypeToInstanceMap")
Reported by PMD.
Line: 58
MutableTypeToInstanceMap<Object> map = new MutableTypeToInstanceMap<>();
for (Object object : elements) {
Entry<TypeToken, Object> entry = (Entry<TypeToken, Object>) object;
map.putInstance(entry.getKey(), entry.getValue());
}
return (Map) map;
}
})
.named("MutableTypeToInstanceMap")
Reported by PMD.
guava-tests/test/com/google/common/reflect/MutableTypeToInstanceMapTest.java
104 issues
Line: 85
public void testPutThrows() {
try {
map.put(TypeToken.of(Integer.class), new Integer(5));
fail();
} catch (UnsupportedOperationException expected) {
}
}
Reported by PMD.
Line: 93
public void testPutAllThrows() {
try {
map.putAll(ImmutableMap.of(TypeToken.of(Integer.class), new Integer(5)));
fail();
} catch (UnsupportedOperationException expected) {
}
}
Reported by PMD.
Line: 137
}
public void testPutAndGetInstance() {
assertNull(map.putInstance(Integer.class, new Integer(5)));
Integer oldValue = map.putInstance(Integer.class, new Integer(7));
assertEquals(5, (int) oldValue);
Integer newValue = map.getInstance(Integer.class);
Reported by PMD.
Line: 139
public void testPutAndGetInstance() {
assertNull(map.putInstance(Integer.class, new Integer(5)));
Integer oldValue = map.putInstance(Integer.class, new Integer(7));
assertEquals(5, (int) oldValue);
Integer newValue = map.getInstance(Integer.class);
assertEquals(7, (int) newValue);
assertEquals(7, (int) map.getInstance(TypeToken.of(Integer.class)));
Reported by PMD.
Line: 151
public void testNull() {
try {
map.putInstance((TypeToken) null, new Integer(1));
fail();
} catch (NullPointerException expected) {
}
map.putInstance(Integer.class, null);
assertTrue(map.containsKey(TypeToken.of(Integer.class)));
Reported by PMD.
Line: 40
*
* @author Ben Yu
*/
public class MutableTypeToInstanceMapTest extends TestCase {
@AndroidIncompatible // problem with suite builders on Android
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTestSuite(MutableTypeToInstanceMapTest.class);
Reported by PMD.
Line: 42
*/
public class MutableTypeToInstanceMapTest extends TestCase {
@AndroidIncompatible // problem with suite builders on Android
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTestSuite(MutableTypeToInstanceMapTest.class);
suite.addTest(
Reported by PMD.
Line: 53
// Other tests will verify what real, warning-free usage looks like
// but here we have to do some serious fudging
@Override
@SuppressWarnings("unchecked")
public Map<TypeToken, Object> create(Object... elements) {
MutableTypeToInstanceMap<Object> map = new MutableTypeToInstanceMap<>();
for (Object object : elements) {
Entry<TypeToken, Object> entry = (Entry<TypeToken, Object>) object;
map.putInstance(entry.getKey(), entry.getValue());
Reported by PMD.
Line: 58
MutableTypeToInstanceMap<Object> map = new MutableTypeToInstanceMap<>();
for (Object object : elements) {
Entry<TypeToken, Object> entry = (Entry<TypeToken, Object>) object;
map.putInstance(entry.getKey(), entry.getValue());
}
return (Map) map;
}
})
.named("MutableTypeToInstanceMap")
Reported by PMD.
Line: 58
MutableTypeToInstanceMap<Object> map = new MutableTypeToInstanceMap<>();
for (Object object : elements) {
Entry<TypeToken, Object> entry = (Entry<TypeToken, Object>) object;
map.putInstance(entry.getKey(), entry.getValue());
}
return (Map) map;
}
})
.named("MutableTypeToInstanceMap")
Reported by PMD.
android/guava-tests/test/com/google/common/math/StatsTesting.java
104 issues
Line: 41
*
* @author Pete Gillin
*/
class StatsTesting {
static final double ALLOWED_ERROR = 1e-10;
// Inputs and their statistics:
Reported by PMD.
Line: 76
*/
static class ManyValues {
private final ImmutableList<Double> values;
ManyValues(double[] values) {
this.values = ImmutableList.copyOf(Doubles.asList(values));
}
Reported by PMD.
Line: 122
values[3] = 555.555;
for (double fifth : ImmutableList.of(-2.2, POSITIVE_INFINITY, NEGATIVE_INFINITY, NaN)) {
values[4] = fifth;
builder.add(new ManyValues(values));
}
}
}
return builder.build();
}
Reported by PMD.
Line: 289
private static PairedStats buildManyValuesPairedStats() {
PairedStatsAccumulator accumulator =
createFilledPairedStatsAccumulator(MANY_VALUES, OTHER_MANY_VALUES);
PairedStats stats = accumulator.snapshot();
accumulator.add(99.99, 9999.9999); // should do nothing to the snapshot
return stats;
}
private static PairedStats buildHorizontalValuesPairedStats() {
Reported by PMD.
Line: 290
PairedStatsAccumulator accumulator =
createFilledPairedStatsAccumulator(MANY_VALUES, OTHER_MANY_VALUES);
PairedStats stats = accumulator.snapshot();
accumulator.add(99.99, 9999.9999); // should do nothing to the snapshot
return stats;
}
private static PairedStats buildHorizontalValuesPairedStats() {
PairedStatsAccumulator accumulator = new PairedStatsAccumulator();
Reported by PMD.
Line: 332
// Helper methods:
static void assertStatsApproxEqual(Stats expectedStats, Stats actualStats) {
assertThat(actualStats.count()).isEqualTo(expectedStats.count());
if (expectedStats.count() == 0) {
try {
actualStats.mean();
fail("Expected IllegalStateException");
} catch (IllegalStateException expected) {
Reported by PMD.
Line: 336
if (expectedStats.count() == 0) {
try {
actualStats.mean();
fail("Expected IllegalStateException");
} catch (IllegalStateException expected) {
}
try {
actualStats.populationVariance();
fail("Expected IllegalStateException");
Reported by PMD.
Line: 354
fail("Expected IllegalStateException");
} catch (IllegalStateException expected) {
}
} else if (expectedStats.count() == 1) {
assertThat(actualStats.mean()).isWithin(ALLOWED_ERROR).of(expectedStats.mean());
assertThat(actualStats.populationVariance()).isWithin(0.0).of(0.0);
assertThat(actualStats.min()).isWithin(ALLOWED_ERROR).of(expectedStats.min());
assertThat(actualStats.max()).isWithin(ALLOWED_ERROR).of(expectedStats.max());
} else {
Reported by PMD.
Line: 355
} catch (IllegalStateException expected) {
}
} else if (expectedStats.count() == 1) {
assertThat(actualStats.mean()).isWithin(ALLOWED_ERROR).of(expectedStats.mean());
assertThat(actualStats.populationVariance()).isWithin(0.0).of(0.0);
assertThat(actualStats.min()).isWithin(ALLOWED_ERROR).of(expectedStats.min());
assertThat(actualStats.max()).isWithin(ALLOWED_ERROR).of(expectedStats.max());
} else {
assertThat(actualStats.mean()).isWithin(ALLOWED_ERROR).of(expectedStats.mean());
Reported by PMD.
Line: 355
} catch (IllegalStateException expected) {
}
} else if (expectedStats.count() == 1) {
assertThat(actualStats.mean()).isWithin(ALLOWED_ERROR).of(expectedStats.mean());
assertThat(actualStats.populationVariance()).isWithin(0.0).of(0.0);
assertThat(actualStats.min()).isWithin(ALLOWED_ERROR).of(expectedStats.min());
assertThat(actualStats.max()).isWithin(ALLOWED_ERROR).of(expectedStats.max());
} else {
assertThat(actualStats.mean()).isWithin(ALLOWED_ERROR).of(expectedStats.mean());
Reported by PMD.
guava/src/com/google/common/collect/Multisets.java
103 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.CollectPreconditions.checkNonnegative;
import static com.google.common.collect.CollectPreconditions.checkRemove;
Reported by PMD.
Line: 64
*/
@GwtCompatible
@ElementTypesAreNonnullByDefault
public final class Multisets {
private Multisets() {}
/**
* Returns a {@code Collector} that accumulates elements into a multiset created via the specified
* {@code Supplier}, whose elements are the result of applying {@code elementFunction} to the
Reported by PMD.
Line: 64
*/
@GwtCompatible
@ElementTypesAreNonnullByDefault
public final class Multisets {
private Multisets() {}
/**
* Returns a {@code Collector} that accumulates elements into a multiset created via the specified
* {@code Supplier}, whose elements are the result of applying {@code elementFunction} to the
Reported by PMD.
Line: 64
*/
@GwtCompatible
@ElementTypesAreNonnullByDefault
public final class Multisets {
private Multisets() {}
/**
* Returns a {@code Collector} that accumulates elements into a multiset created via the specified
* {@code Supplier}, whose elements are the result of applying {@code elementFunction} to the
Reported by PMD.
Line: 64
*/
@GwtCompatible
@ElementTypesAreNonnullByDefault
public final class Multisets {
private Multisets() {}
/**
* Returns a {@code Collector} that accumulates elements into a multiset created via the specified
* {@code Supplier}, whose elements are the result of applying {@code elementFunction} to the
Reported by PMD.
Line: 64
*/
@GwtCompatible
@ElementTypesAreNonnullByDefault
public final class Multisets {
private Multisets() {}
/**
* Returns a {@code Collector} that accumulates elements into a multiset created via the specified
* {@code Supplier}, whose elements are the result of applying {@code elementFunction} to the
Reported by PMD.
Line: 105
public static <E extends @Nullable Object> Multiset<E> unmodifiableMultiset(
Multiset<? extends E> multiset) {
if (multiset instanceof UnmodifiableMultiset || multiset instanceof ImmutableMultiset) {
@SuppressWarnings("unchecked") // Since it's unmodifiable, the covariant cast is safe
Multiset<E> result = (Multiset<E>) multiset;
return result;
}
return new UnmodifiableMultiset<E>(checkNotNull(multiset));
}
Reported by PMD.
Line: 124
}
static class UnmodifiableMultiset<E extends @Nullable Object> extends ForwardingMultiset<E>
implements Serializable {
final Multiset<? extends E> delegate;
UnmodifiableMultiset(Multiset<? extends E> delegate) {
this.delegate = delegate;
}
Reported by PMD.
Line: 125
static class UnmodifiableMultiset<E extends @Nullable Object> extends ForwardingMultiset<E>
implements Serializable {
final Multiset<? extends E> delegate;
UnmodifiableMultiset(Multiset<? extends E> delegate) {
this.delegate = delegate;
}
Reported by PMD.
Line: 125
static class UnmodifiableMultiset<E extends @Nullable Object> extends ForwardingMultiset<E>
implements Serializable {
final Multiset<? extends E> delegate;
UnmodifiableMultiset(Multiset<? extends E> delegate) {
this.delegate = delegate;
}
Reported by PMD.
android/guava-tests/test/com/google/common/eventbus/outside/AnnotatedSubscriberFinderTests.java
103 issues
Line: 17
* limitations under the License.
*/
package com.google.common.eventbus.outside;
import static com.google.common.truth.Truth.assertThat;
import com.google.common.collect.Lists;
import com.google.common.eventbus.EventBus;
Reported by PMD.
Line: 41
abstract static class AbstractEventBusTest<H> extends TestCase {
abstract H createSubscriber();
private H subscriber;
H getSubscriber() {
return subscriber;
}
Reported by PMD.
Line: 47
return subscriber;
}
@Override
protected void setUp() throws Exception {
subscriber = createSubscriber();
EventBus bus = new EventBus();
bus.register(subscriber);
bus.post(EVENT);
Reported by PMD.
Line: 55
bus.post(EVENT);
}
@Override
protected void tearDown() throws Exception {
subscriber = null;
}
}
Reported by PMD.
Line: 57
@Override
protected void tearDown() throws Exception {
subscriber = null;
}
}
/*
* We break the tests up based on whether they are annotated or abstract in the superclass.
Reported by PMD.
Line: 67
public static class BaseSubscriberFinderTest
extends AbstractEventBusTest<BaseSubscriberFinderTest.Subscriber> {
static class Subscriber {
final List<Object> nonSubscriberEvents = Lists.newArrayList();
final List<Object> subscriberEvents = Lists.newArrayList();
public void notASubscriber(Object o) {
nonSubscriberEvents.add(o);
}
Reported by PMD.
Line: 68
extends AbstractEventBusTest<BaseSubscriberFinderTest.Subscriber> {
static class Subscriber {
final List<Object> nonSubscriberEvents = Lists.newArrayList();
final List<Object> subscriberEvents = Lists.newArrayList();
public void notASubscriber(Object o) {
nonSubscriberEvents.add(o);
}
Reported by PMD.
Line: 80
}
}
public void testNonSubscriber() {
assertThat(getSubscriber().nonSubscriberEvents).isEmpty();
}
public void testSubscriber() {
assertThat(getSubscriber().subscriberEvents).contains(EVENT);
Reported by PMD.
Line: 81
}
public void testNonSubscriber() {
assertThat(getSubscriber().nonSubscriberEvents).isEmpty();
}
public void testSubscriber() {
assertThat(getSubscriber().subscriberEvents).contains(EVENT);
}
Reported by PMD.
Line: 81
}
public void testNonSubscriber() {
assertThat(getSubscriber().nonSubscriberEvents).isEmpty();
}
public void testSubscriber() {
assertThat(getSubscriber().subscriberEvents).contains(EVENT);
}
Reported by PMD.
guava-tests/test/com/google/common/eventbus/outside/AnnotatedSubscriberFinderTests.java
103 issues
Line: 17
* limitations under the License.
*/
package com.google.common.eventbus.outside;
import static com.google.common.truth.Truth.assertThat;
import com.google.common.collect.Lists;
import com.google.common.eventbus.EventBus;
Reported by PMD.
Line: 41
abstract static class AbstractEventBusTest<H> extends TestCase {
abstract H createSubscriber();
private H subscriber;
H getSubscriber() {
return subscriber;
}
Reported by PMD.
Line: 47
return subscriber;
}
@Override
protected void setUp() throws Exception {
subscriber = createSubscriber();
EventBus bus = new EventBus();
bus.register(subscriber);
bus.post(EVENT);
Reported by PMD.
Line: 55
bus.post(EVENT);
}
@Override
protected void tearDown() throws Exception {
subscriber = null;
}
}
Reported by PMD.
Line: 57
@Override
protected void tearDown() throws Exception {
subscriber = null;
}
}
/*
* We break the tests up based on whether they are annotated or abstract in the superclass.
Reported by PMD.
Line: 67
public static class BaseSubscriberFinderTest
extends AbstractEventBusTest<BaseSubscriberFinderTest.Subscriber> {
static class Subscriber {
final List<Object> nonSubscriberEvents = Lists.newArrayList();
final List<Object> subscriberEvents = Lists.newArrayList();
public void notASubscriber(Object o) {
nonSubscriberEvents.add(o);
}
Reported by PMD.
Line: 68
extends AbstractEventBusTest<BaseSubscriberFinderTest.Subscriber> {
static class Subscriber {
final List<Object> nonSubscriberEvents = Lists.newArrayList();
final List<Object> subscriberEvents = Lists.newArrayList();
public void notASubscriber(Object o) {
nonSubscriberEvents.add(o);
}
Reported by PMD.
Line: 80
}
}
public void testNonSubscriber() {
assertThat(getSubscriber().nonSubscriberEvents).isEmpty();
}
public void testSubscriber() {
assertThat(getSubscriber().subscriberEvents).contains(EVENT);
Reported by PMD.
Line: 81
}
public void testNonSubscriber() {
assertThat(getSubscriber().nonSubscriberEvents).isEmpty();
}
public void testSubscriber() {
assertThat(getSubscriber().subscriberEvents).contains(EVENT);
}
Reported by PMD.
Line: 81
}
public void testNonSubscriber() {
assertThat(getSubscriber().nonSubscriberEvents).isEmpty();
}
public void testSubscriber() {
assertThat(getSubscriber().subscriberEvents).contains(EVENT);
}
Reported by PMD.
android/guava/src/com/google/common/collect/Multisets.java
101 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.CollectPreconditions.checkNonnegative;
import static com.google.common.collect.CollectPreconditions.checkRemove;
Reported by PMD.
Line: 59
*/
@GwtCompatible
@ElementTypesAreNonnullByDefault
public final class Multisets {
private Multisets() {}
/**
* Returns an unmodifiable view of the specified multiset. Query operations on the returned
* multiset "read through" to the specified multiset, and attempts to modify the returned multiset
Reported by PMD.
Line: 59
*/
@GwtCompatible
@ElementTypesAreNonnullByDefault
public final class Multisets {
private Multisets() {}
/**
* Returns an unmodifiable view of the specified multiset. Query operations on the returned
* multiset "read through" to the specified multiset, and attempts to modify the returned multiset
Reported by PMD.
Line: 59
*/
@GwtCompatible
@ElementTypesAreNonnullByDefault
public final class Multisets {
private Multisets() {}
/**
* Returns an unmodifiable view of the specified multiset. Query operations on the returned
* multiset "read through" to the specified multiset, and attempts to modify the returned multiset
Reported by PMD.
Line: 59
*/
@GwtCompatible
@ElementTypesAreNonnullByDefault
public final class Multisets {
private Multisets() {}
/**
* Returns an unmodifiable view of the specified multiset. Query operations on the returned
* multiset "read through" to the specified multiset, and attempts to modify the returned multiset
Reported by PMD.
Line: 59
*/
@GwtCompatible
@ElementTypesAreNonnullByDefault
public final class Multisets {
private Multisets() {}
/**
* Returns an unmodifiable view of the specified multiset. Query operations on the returned
* multiset "read through" to the specified multiset, and attempts to modify the returned multiset
Reported by PMD.
Line: 75
public static <E extends @Nullable Object> Multiset<E> unmodifiableMultiset(
Multiset<? extends E> multiset) {
if (multiset instanceof UnmodifiableMultiset || multiset instanceof ImmutableMultiset) {
@SuppressWarnings("unchecked") // Since it's unmodifiable, the covariant cast is safe
Multiset<E> result = (Multiset<E>) multiset;
return result;
}
return new UnmodifiableMultiset<E>(checkNotNull(multiset));
}
Reported by PMD.
Line: 94
}
static class UnmodifiableMultiset<E extends @Nullable Object> extends ForwardingMultiset<E>
implements Serializable {
final Multiset<? extends E> delegate;
UnmodifiableMultiset(Multiset<? extends E> delegate) {
this.delegate = delegate;
}
Reported by PMD.
Line: 95
static class UnmodifiableMultiset<E extends @Nullable Object> extends ForwardingMultiset<E>
implements Serializable {
final Multiset<? extends E> delegate;
UnmodifiableMultiset(Multiset<? extends E> delegate) {
this.delegate = delegate;
}
Reported by PMD.
Line: 95
static class UnmodifiableMultiset<E extends @Nullable Object> extends ForwardingMultiset<E>
implements Serializable {
final Multiset<? extends E> delegate;
UnmodifiableMultiset(Multiset<? extends E> delegate) {
this.delegate = delegate;
}
Reported by PMD.
guava-tests/test/com/google/common/collect/GeneralRangeTest.java
99 issues
Line: 34
* @author Louis Wasserman
*/
@GwtCompatible(emulated = true)
public class GeneralRangeTest extends TestCase {
private static final Ordering<Integer> ORDERING = Ordering.natural().nullsFirst();
private static final List<Integer> IN_ORDER_VALUES = Arrays.asList(null, 1, 2, 3, 4, 5);
public void testCreateEmptyRangeFails() {
Reported by PMD.
Line: 39
private static final List<Integer> IN_ORDER_VALUES = Arrays.asList(null, 1, 2, 3, 4, 5);
public void testCreateEmptyRangeFails() {
for (BoundType lboundType : BoundType.values()) {
for (BoundType uboundType : BoundType.values()) {
try {
GeneralRange.range(ORDERING, 4, lboundType, 2, uboundType);
fail("Expected IAE");
Reported by PMD.
Line: 44
for (BoundType uboundType : BoundType.values()) {
try {
GeneralRange.range(ORDERING, 4, lboundType, 2, uboundType);
fail("Expected IAE");
} catch (IllegalArgumentException expected) {
}
}
}
}
Reported by PMD.
Line: 51
}
}
public void testCreateEmptyRangeOpenOpenFails() {
for (Integer i : IN_ORDER_VALUES) {
try {
GeneralRange.range(ORDERING, i, OPEN, i, OPEN);
fail("Expected IAE");
} catch (IllegalArgumentException expected) {
Reported by PMD.
Line: 55
for (Integer i : IN_ORDER_VALUES) {
try {
GeneralRange.range(ORDERING, i, OPEN, i, OPEN);
fail("Expected IAE");
} catch (IllegalArgumentException expected) {
}
}
}
Reported by PMD.
Line: 61
}
}
public void testCreateEmptyRangeClosedOpenSucceeds() {
for (Integer i : IN_ORDER_VALUES) {
GeneralRange<Integer> range = GeneralRange.range(ORDERING, i, CLOSED, i, OPEN);
for (Integer j : IN_ORDER_VALUES) {
assertFalse(range.contains(j));
}
Reported by PMD.
Line: 65
for (Integer i : IN_ORDER_VALUES) {
GeneralRange<Integer> range = GeneralRange.range(ORDERING, i, CLOSED, i, OPEN);
for (Integer j : IN_ORDER_VALUES) {
assertFalse(range.contains(j));
}
}
}
public void testCreateEmptyRangeOpenClosedSucceeds() {
Reported by PMD.
Line: 65
for (Integer i : IN_ORDER_VALUES) {
GeneralRange<Integer> range = GeneralRange.range(ORDERING, i, CLOSED, i, OPEN);
for (Integer j : IN_ORDER_VALUES) {
assertFalse(range.contains(j));
}
}
}
public void testCreateEmptyRangeOpenClosedSucceeds() {
Reported by PMD.
Line: 70
}
}
public void testCreateEmptyRangeOpenClosedSucceeds() {
for (Integer i : IN_ORDER_VALUES) {
GeneralRange<Integer> range = GeneralRange.range(ORDERING, i, OPEN, i, CLOSED);
for (Integer j : IN_ORDER_VALUES) {
assertFalse(range.contains(j));
}
Reported by PMD.
Line: 74
for (Integer i : IN_ORDER_VALUES) {
GeneralRange<Integer> range = GeneralRange.range(ORDERING, i, OPEN, i, CLOSED);
for (Integer j : IN_ORDER_VALUES) {
assertFalse(range.contains(j));
}
}
}
public void testCreateSingletonRangeSucceeds() {
Reported by PMD.
android/guava-tests/test/com/google/common/collect/GeneralRangeTest.java
99 issues
Line: 34
* @author Louis Wasserman
*/
@GwtCompatible(emulated = true)
public class GeneralRangeTest extends TestCase {
private static final Ordering<Integer> ORDERING = Ordering.natural().nullsFirst();
private static final List<Integer> IN_ORDER_VALUES = Arrays.asList(null, 1, 2, 3, 4, 5);
public void testCreateEmptyRangeFails() {
Reported by PMD.
Line: 39
private static final List<Integer> IN_ORDER_VALUES = Arrays.asList(null, 1, 2, 3, 4, 5);
public void testCreateEmptyRangeFails() {
for (BoundType lboundType : BoundType.values()) {
for (BoundType uboundType : BoundType.values()) {
try {
GeneralRange.range(ORDERING, 4, lboundType, 2, uboundType);
fail("Expected IAE");
Reported by PMD.
Line: 44
for (BoundType uboundType : BoundType.values()) {
try {
GeneralRange.range(ORDERING, 4, lboundType, 2, uboundType);
fail("Expected IAE");
} catch (IllegalArgumentException expected) {
}
}
}
}
Reported by PMD.
Line: 51
}
}
public void testCreateEmptyRangeOpenOpenFails() {
for (Integer i : IN_ORDER_VALUES) {
try {
GeneralRange.range(ORDERING, i, OPEN, i, OPEN);
fail("Expected IAE");
} catch (IllegalArgumentException expected) {
Reported by PMD.
Line: 55
for (Integer i : IN_ORDER_VALUES) {
try {
GeneralRange.range(ORDERING, i, OPEN, i, OPEN);
fail("Expected IAE");
} catch (IllegalArgumentException expected) {
}
}
}
Reported by PMD.
Line: 61
}
}
public void testCreateEmptyRangeClosedOpenSucceeds() {
for (Integer i : IN_ORDER_VALUES) {
GeneralRange<Integer> range = GeneralRange.range(ORDERING, i, CLOSED, i, OPEN);
for (Integer j : IN_ORDER_VALUES) {
assertFalse(range.contains(j));
}
Reported by PMD.
Line: 65
for (Integer i : IN_ORDER_VALUES) {
GeneralRange<Integer> range = GeneralRange.range(ORDERING, i, CLOSED, i, OPEN);
for (Integer j : IN_ORDER_VALUES) {
assertFalse(range.contains(j));
}
}
}
public void testCreateEmptyRangeOpenClosedSucceeds() {
Reported by PMD.
Line: 65
for (Integer i : IN_ORDER_VALUES) {
GeneralRange<Integer> range = GeneralRange.range(ORDERING, i, CLOSED, i, OPEN);
for (Integer j : IN_ORDER_VALUES) {
assertFalse(range.contains(j));
}
}
}
public void testCreateEmptyRangeOpenClosedSucceeds() {
Reported by PMD.
Line: 70
}
}
public void testCreateEmptyRangeOpenClosedSucceeds() {
for (Integer i : IN_ORDER_VALUES) {
GeneralRange<Integer> range = GeneralRange.range(ORDERING, i, OPEN, i, CLOSED);
for (Integer j : IN_ORDER_VALUES) {
assertFalse(range.contains(j));
}
Reported by PMD.
Line: 74
for (Integer i : IN_ORDER_VALUES) {
GeneralRange<Integer> range = GeneralRange.range(ORDERING, i, OPEN, i, CLOSED);
for (Integer j : IN_ORDER_VALUES) {
assertFalse(range.contains(j));
}
}
}
public void testCreateSingletonRangeSucceeds() {
Reported by PMD.