The following issues were found
guava/src/com/google/common/cache/LongAdder.java
8 issues
Line: 44
*/
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
final class LongAdder extends Striped64 implements Serializable, LongAddable {
private static final long serialVersionUID = 7249069246863182397L;
/** Version of plus for use in retryUpdate */
@Override
final long fn(long v, long x) {
Reported by PMD.
Line: 68
int[] hc;
Cell a;
int n;
if ((as = cells) != null || !casBase(b = base, b + x)) {
boolean uncontended = true;
if ((hc = threadHashCode.get()) == null
|| as == null
|| (n = as.length) < 1
|| (a = as[(n - 1) & hc[0]]) == null
Reported by PMD.
Line: 70
int n;
if ((as = cells) != null || !casBase(b = base, b + x)) {
boolean uncontended = true;
if ((hc = threadHashCode.get()) == null
|| as == null
|| (n = as.length) < 1
|| (a = as[(n - 1) & hc[0]]) == null
|| !(uncontended = a.cas(v = a.value, v + x))) retryUpdate(x, hc, uncontended);
}
Reported by PMD.
Line: 191
private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException {
s.defaultReadObject();
busy = 0;
cells = null;
base = s.readLong();
}
}
Reported by PMD.
Line: 64
@Override
public void add(long x) {
Cell[] as;
long b, v;
int[] hc;
Cell a;
int n;
if ((as = cells) != null || !casBase(b = base, b + x)) {
boolean uncontended = true;
Reported by PMD.
Line: 68
int[] hc;
Cell a;
int n;
if ((as = cells) != null || !casBase(b = base, b + x)) {
boolean uncontended = true;
if ((hc = threadHashCode.get()) == null
|| as == null
|| (n = as.length) < 1
|| (a = as[(n - 1) & hc[0]]) == null
Reported by PMD.
Line: 69
Cell a;
int n;
if ((as = cells) != null || !casBase(b = base, b + x)) {
boolean uncontended = true;
if ((hc = threadHashCode.get()) == null
|| as == null
|| (n = as.length) < 1
|| (a = as[(n - 1) & hc[0]]) == null
|| !(uncontended = a.cas(v = a.value, v + x))) retryUpdate(x, hc, uncontended);
Reported by PMD.
Line: 70
int n;
if ((as = cells) != null || !casBase(b = base, b + x)) {
boolean uncontended = true;
if ((hc = threadHashCode.get()) == null
|| as == null
|| (n = as.length) < 1
|| (a = as[(n - 1) & hc[0]]) == null
|| !(uncontended = a.cas(v = a.value, v + x))) retryUpdate(x, hc, uncontended);
}
Reported by PMD.
guava-testlib/src/com/google/common/collect/testing/google/MultimapForEachTester.java
8 issues
Line: 38
@GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MultimapForEachTester<K, V> extends AbstractMultimapTester<K, V, Multimap<K, V>> {
public void testForEach() {
List<Entry<K, V>> entries = new ArrayList<>();
multimap().forEach((k, v) -> entries.add(mapEntry(k, v)));
assertEqualIgnoringOrder(getSampleElements(), multimap().entries());
}
Reported by PMD.
Line: 40
public class MultimapForEachTester<K, V> extends AbstractMultimapTester<K, V, Multimap<K, V>> {
public void testForEach() {
List<Entry<K, V>> entries = new ArrayList<>();
multimap().forEach((k, v) -> entries.add(mapEntry(k, v)));
assertEqualIgnoringOrder(getSampleElements(), multimap().entries());
}
@CollectionFeature.Require(KNOWN_ORDER)
public void testForEachOrder() {
Reported by PMD.
Line: 41
public void testForEach() {
List<Entry<K, V>> entries = new ArrayList<>();
multimap().forEach((k, v) -> entries.add(mapEntry(k, v)));
assertEqualIgnoringOrder(getSampleElements(), multimap().entries());
}
@CollectionFeature.Require(KNOWN_ORDER)
public void testForEachOrder() {
List<Entry<K, V>> entries = new ArrayList<>();
Reported by PMD.
Line: 44
assertEqualIgnoringOrder(getSampleElements(), multimap().entries());
}
@CollectionFeature.Require(KNOWN_ORDER)
public void testForEachOrder() {
List<Entry<K, V>> entries = new ArrayList<>();
multimap().forEach((k, v) -> entries.add(mapEntry(k, v)));
assertEqualIgnoringOrder(getSampleElements(), multimap().entries());
}
Reported by PMD.
Line: 47
@CollectionFeature.Require(KNOWN_ORDER)
public void testForEachOrder() {
List<Entry<K, V>> entries = new ArrayList<>();
multimap().forEach((k, v) -> entries.add(mapEntry(k, v)));
assertEqualIgnoringOrder(getSampleElements(), multimap().entries());
}
}
Reported by PMD.
Line: 48
public void testForEachOrder() {
List<Entry<K, V>> entries = new ArrayList<>();
multimap().forEach((k, v) -> entries.add(mapEntry(k, v)));
assertEqualIgnoringOrder(getSampleElements(), multimap().entries());
}
}
Reported by PMD.
Line: 39
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MultimapForEachTester<K, V> extends AbstractMultimapTester<K, V, Multimap<K, V>> {
public void testForEach() {
List<Entry<K, V>> entries = new ArrayList<>();
multimap().forEach((k, v) -> entries.add(mapEntry(k, v)));
assertEqualIgnoringOrder(getSampleElements(), multimap().entries());
}
@CollectionFeature.Require(KNOWN_ORDER)
Reported by PMD.
Line: 46
@CollectionFeature.Require(KNOWN_ORDER)
public void testForEachOrder() {
List<Entry<K, V>> entries = new ArrayList<>();
multimap().forEach((k, v) -> entries.add(mapEntry(k, v)));
assertEqualIgnoringOrder(getSampleElements(), multimap().entries());
}
}
Reported by PMD.
guava-testlib/src/com/google/common/collect/testing/AbstractCollectionTester.java
8 issues
Line: 35
extends AbstractContainerTester<Collection<E>, E> {
// TODO: replace this with an accessor.
protected Collection<E> collection;
@Override
protected Collection<E> actualContents() {
return collection;
}
Reported by PMD.
Line: 57
/** @return an array of the proper size with {@code null} inserted into the middle element. */
protected E[] createArrayWithNullElement() {
E[] array = createSamplesArray();
array[getNullLocation()] = null;
return array;
}
protected void initCollectionWithNullElement() {
E[] array = createArrayWithNullElement();
Reported by PMD.
Line: 63
protected void initCollectionWithNullElement() {
E[] array = createArrayWithNullElement();
resetContainer(getSubjectGenerator().create(array));
}
/**
* Equivalent to {@link #expectMissing(Object[]) expectMissing}{@code (null)} except that the call
* to {@code contains(null)} is permitted to throw a {@code NullPointerException}.
Reported by PMD.
Line: 74
*/
protected void expectNullMissingWhenNullUnsupported(String message) {
try {
assertFalse(message, actualContents().contains(null));
} catch (NullPointerException tolerated) {
// Tolerated
}
}
}
Reported by PMD.
Line: 75
protected void expectNullMissingWhenNullUnsupported(String message) {
try {
assertFalse(message, actualContents().contains(null));
} catch (NullPointerException tolerated) {
// Tolerated
}
}
}
Reported by PMD.
Line: 75
protected void expectNullMissingWhenNullUnsupported(String message) {
try {
assertFalse(message, actualContents().contains(null));
} catch (NullPointerException tolerated) {
// Tolerated
}
}
}
Reported by PMD.
Line: 75
protected void expectNullMissingWhenNullUnsupported(String message) {
try {
assertFalse(message, actualContents().contains(null));
} catch (NullPointerException tolerated) {
// Tolerated
}
}
}
Reported by PMD.
Line: 56
/** @return an array of the proper size with {@code null} inserted into the middle element. */
protected E[] createArrayWithNullElement() {
E[] array = createSamplesArray();
array[getNullLocation()] = null;
return array;
}
protected void initCollectionWithNullElement() {
Reported by PMD.
android/guava/src/com/google/common/collect/ImmutableCollection.java
8 issues
Line: 219
/** If this collection is backed by an array of its elements in insertion order, returns it. */
@CheckForNull
@Nullable
Object[] internalArray() {
return null;
}
/**
* If this collection is backed by an array of its elements in insertion order, returns the offset
Reported by PMD.
Line: 199
* nullness perspective. The signature below at least has the virtue of being relatively simple.
*/
@SuppressWarnings("nullness")
public final <T extends @Nullable Object> T[] toArray(T[] other) {
checkNotNull(other);
int size = size();
if (other.length < size) {
Object[] internal = internalArray();
Reported by PMD.
Line: 352
* offset. Returns {@code offset + size()}.
*/
@CanIgnoreReturnValue
int copyIntoArray(@Nullable Object[] dst, int offset) {
for (E e : this) {
dst[offset++] = e;
}
return offset;
}
Reported by PMD.
Line: 169
@ElementTypesAreNonnullByDefault
// TODO(kevinb): I think we should push everything down to "BaseImmutableCollection" or something,
// just to do everything we can to emphasize the "practically an interface" nature of this class.
public abstract class ImmutableCollection<E> extends AbstractCollection<E> implements Serializable {
ImmutableCollection() {}
/** Returns an unmodifiable iterator across the elements in this collection. */
@Override
Reported by PMD.
Line: 210
}
other = ObjectArrays.newArray(other, size);
} else if (other.length > size) {
other[size] = null;
}
copyIntoArray(other, 0);
return other;
}
Reported by PMD.
Line: 251
@CanIgnoreReturnValue
@Deprecated
@Override
@DoNotCall("Always throws UnsupportedOperationException")
public final boolean add(E e) {
throw new UnsupportedOperationException();
}
/**
Reported by PMD.
Line: 531
public Builder<E> addAll(Iterable<? extends E> elements) {
if (elements instanceof Collection) {
Collection<?> collection = (Collection<?>) elements;
getReadyToExpandTo(size + collection.size());
if (collection instanceof ImmutableCollection) {
ImmutableCollection<?> immutableCollection = (ImmutableCollection<?>) collection;
size = immutableCollection.copyIntoArray(contents, size);
return this;
}
Reported by PMD.
Line: 534
getReadyToExpandTo(size + collection.size());
if (collection instanceof ImmutableCollection) {
ImmutableCollection<?> immutableCollection = (ImmutableCollection<?>) collection;
size = immutableCollection.copyIntoArray(contents, size);
return this;
}
}
super.addAll(elements);
return this;
Reported by PMD.
guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/ImmutableBiMap.java
8 issues
Line: 33
* @author Hayward Chan
*/
public abstract class ImmutableBiMap<K, V> extends ForwardingImmutableMap<K, V>
implements BiMap<K, V> {
public static <T, K, V> Collector<T, ?, ImmutableBiMap<K, V>> toImmutableBiMap(
Function<? super T, ? extends K> keyFunction,
Function<? super T, ? extends V> valueFunction) {
return CollectCollectors.toImmutableBiMap(keyFunction, valueFunction);
}
Reported by PMD.
Line: 63
return new RegularImmutableBiMap<K, V>(ImmutableMap.of(k1, v1, k2, v2, k3, v3, k4, v4));
}
public static <K, V> ImmutableBiMap<K, V> of(
K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5) {
return new RegularImmutableBiMap<K, V>(ImmutableMap.of(k1, v1, k2, v2, k3, v3, k4, v4, k5, v5));
}
public static <K, V> Builder<K, V> builder() {
Reported by PMD.
Line: 104
return this;
}
public Builder<K, V> orderEntriesByValue(Comparator<? super V> valueComparator) {
super.orderEntriesByValue(valueComparator);
return this;
}
Builder<K, V> combine(Builder<K, V> other) {
Reported by PMD.
Line: 109
return this;
}
Builder<K, V> combine(Builder<K, V> other) {
super.combine(other);
return this;
}
@Override
Reported by PMD.
Line: 117
@Override
public ImmutableBiMap<K, V> build() {
ImmutableMap<K, V> map = super.build();
if (map.isEmpty()) {
return of();
}
return new RegularImmutableBiMap<K, V>(super.build());
}
Reported by PMD.
Line: 153
super(delegate);
}
public abstract ImmutableBiMap<V, K> inverse();
@Override
public ImmutableSet<V> values() {
return inverse().keySet();
}
Reported by PMD.
Line: 157
@Override
public ImmutableSet<V> values() {
return inverse().keySet();
}
public final V forcePut(K key, V value) {
throw new UnsupportedOperationException();
}
Reported by PMD.
Line: 160
return inverse().keySet();
}
public final V forcePut(K key, V value) {
throw new UnsupportedOperationException();
}
}
Reported by PMD.
android/guava/src/com/google/common/collect/FilteredMultimapValues.java
8 issues
Line: 40
@ElementTypesAreNonnullByDefault
final class FilteredMultimapValues<K extends @Nullable Object, V extends @Nullable Object>
extends AbstractCollection<V> {
@Weak private final FilteredMultimap<K, V> multimap;
FilteredMultimapValues(FilteredMultimap<K, V> multimap) {
this.multimap = checkNotNull(multimap);
}
Reported by PMD.
Line: 48
@Override
public Iterator<V> iterator() {
return Maps.valueIterator(multimap.entries().iterator());
}
@Override
public boolean contains(@CheckForNull Object o) {
return multimap.containsValue(o);
Reported by PMD.
Line: 64
@Override
public boolean remove(@CheckForNull Object o) {
Predicate<? super Entry<K, V>> entryPredicate = multimap.entryPredicate();
for (Iterator<Entry<K, V>> unfilteredItr = multimap.unfiltered().entries().iterator();
unfilteredItr.hasNext(); ) {
Entry<K, V> entry = unfilteredItr.next();
if (entryPredicate.apply(entry) && Objects.equal(entry.getValue(), o)) {
unfilteredItr.remove();
return true;
Reported by PMD.
Line: 64
@Override
public boolean remove(@CheckForNull Object o) {
Predicate<? super Entry<K, V>> entryPredicate = multimap.entryPredicate();
for (Iterator<Entry<K, V>> unfilteredItr = multimap.unfiltered().entries().iterator();
unfilteredItr.hasNext(); ) {
Entry<K, V> entry = unfilteredItr.next();
if (entryPredicate.apply(entry) && Objects.equal(entry.getValue(), o)) {
unfilteredItr.remove();
return true;
Reported by PMD.
Line: 67
for (Iterator<Entry<K, V>> unfilteredItr = multimap.unfiltered().entries().iterator();
unfilteredItr.hasNext(); ) {
Entry<K, V> entry = unfilteredItr.next();
if (entryPredicate.apply(entry) && Objects.equal(entry.getValue(), o)) {
unfilteredItr.remove();
return true;
}
}
return false;
Reported by PMD.
Line: 78
@Override
public boolean removeAll(Collection<?> c) {
return Iterables.removeIf(
multimap.unfiltered().entries(),
// explicit <Entry<K, V>> is required to build with JDK6
Predicates.<Entry<K, V>>and(
multimap.entryPredicate(), Maps.<V>valuePredicateOnEntries(Predicates.in(c))));
}
Reported by PMD.
Line: 87
@Override
public boolean retainAll(Collection<?> c) {
return Iterables.removeIf(
multimap.unfiltered().entries(),
// explicit <Entry<K, V>> is required to build with JDK6
Predicates.<Entry<K, V>>and(
multimap.entryPredicate(),
Maps.<V>valuePredicateOnEntries(Predicates.not(Predicates.in(c)))));
}
Reported by PMD.
Line: 63
@Override
public boolean remove(@CheckForNull Object o) {
Predicate<? super Entry<K, V>> entryPredicate = multimap.entryPredicate();
for (Iterator<Entry<K, V>> unfilteredItr = multimap.unfiltered().entries().iterator();
unfilteredItr.hasNext(); ) {
Entry<K, V> entry = unfilteredItr.next();
if (entryPredicate.apply(entry) && Objects.equal(entry.getValue(), o)) {
unfilteredItr.remove();
Reported by PMD.
android/guava/src/com/google/common/eventbus/Subscriber.java
8 issues
Line: 90
try {
method.invoke(target, checkNotNull(event));
} catch (IllegalArgumentException e) {
throw new Error("Method rejected target/argument: " + event, e);
} catch (IllegalAccessException e) {
throw new Error("Method became inaccessible: " + event, e);
} catch (InvocationTargetException e) {
if (e.getCause() instanceof Error) {
throw (Error) e.getCause();
Reported by PMD.
Line: 92
} catch (IllegalArgumentException e) {
throw new Error("Method rejected target/argument: " + event, e);
} catch (IllegalAccessException e) {
throw new Error("Method became inaccessible: " + event, e);
} catch (InvocationTargetException e) {
if (e.getCause() instanceof Error) {
throw (Error) e.getCause();
}
throw e;
Reported by PMD.
Line: 46
}
/** The event bus this subscriber belongs to. */
@Weak private EventBus bus;
/** The object with the subscriber method. */
@VisibleForTesting final Object target;
/** Subscriber method. */
Reported by PMD.
Line: 46
}
/** The event bus this subscriber belongs to. */
@Weak private EventBus bus;
/** The object with the subscriber method. */
@VisibleForTesting final Object target;
/** Subscriber method. */
Reported by PMD.
Line: 49
@Weak private EventBus bus;
/** The object with the subscriber method. */
@VisibleForTesting final Object target;
/** Subscriber method. */
private final Method method;
/** Executor to use for dispatching events to this subscriber. */
Reported by PMD.
Line: 52
@VisibleForTesting final Object target;
/** Subscriber method. */
private final Method method;
/** Executor to use for dispatching events to this subscriber. */
private final Executor executor;
private Subscriber(EventBus bus, Object target, Method method) {
Reported by PMD.
Line: 55
private final Method method;
/** Executor to use for dispatching events to this subscriber. */
private final Executor executor;
private Subscriber(EventBus bus, Object target, Method method) {
this.bus = bus;
this.target = checkNotNull(target);
this.method = method;
Reported by PMD.
Line: 118
// Use == so that different equal instances will still receive events.
// We only guard against the case that the same object is registered
// multiple times
return target == that.target && method.equals(that.method);
}
return false;
}
/**
Reported by PMD.
android/guava/src/com/google/common/graph/EndpointPairIterator.java
8 issues
Line: 37
*/
@ElementTypesAreNonnullByDefault
abstract class EndpointPairIterator<N> extends AbstractIterator<EndpointPair<N>> {
private final BaseGraph<N> graph;
private final Iterator<N> nodeIterator;
@CheckForNull
N node = null; // null is safe as an initial value because graphs don't allow null nodes
Reported by PMD.
Line: 38
@ElementTypesAreNonnullByDefault
abstract class EndpointPairIterator<N> extends AbstractIterator<EndpointPair<N>> {
private final BaseGraph<N> graph;
private final Iterator<N> nodeIterator;
@CheckForNull
N node = null; // null is safe as an initial value because graphs don't allow null nodes
Iterator<N> successorIterator = ImmutableSet.<N>of().iterator();
Reported by PMD.
Line: 41
private final Iterator<N> nodeIterator;
@CheckForNull
N node = null; // null is safe as an initial value because graphs don't allow null nodes
Iterator<N> successorIterator = ImmutableSet.<N>of().iterator();
static <N> EndpointPairIterator<N> of(BaseGraph<N> graph) {
return graph.isDirected() ? new Directed<N>(graph) : new Undirected<N>(graph);
Reported by PMD.
Line: 41
private final Iterator<N> nodeIterator;
@CheckForNull
N node = null; // null is safe as an initial value because graphs don't allow null nodes
Iterator<N> successorIterator = ImmutableSet.<N>of().iterator();
static <N> EndpointPairIterator<N> of(BaseGraph<N> graph) {
return graph.isDirected() ? new Directed<N>(graph) : new Undirected<N>(graph);
Reported by PMD.
Line: 43
@CheckForNull
N node = null; // null is safe as an initial value because graphs don't allow null nodes
Iterator<N> successorIterator = ImmutableSet.<N>of().iterator();
static <N> EndpointPairIterator<N> of(BaseGraph<N> graph) {
return graph.isDirected() ? new Directed<N>(graph) : new Undirected<N>(graph);
}
Reported by PMD.
Line: 64
return false;
}
node = nodeIterator.next();
successorIterator = graph.successors(node).iterator();
return true;
}
/**
* If the graph is directed, each ordered [source, target] pair will be visited once if there is
Reported by PMD.
Line: 120
*/
private static final class Undirected<N> extends EndpointPairIterator<N> {
// It's a little weird that we add `null` to this set, but it makes for slightly simpler code.
@CheckForNull private Set<@Nullable N> visitedNodes;
private Undirected(BaseGraph<N> graph) {
super(graph);
this.visitedNodes = Sets.newHashSetWithExpectedSize(graph.nodes().size() + 1);
}
Reported by PMD.
Line: 146
// Add to visited set *after* processing neighbors so we still include self-loops.
visitedNodes.add(node);
if (!advance()) {
visitedNodes = null;
return endOfData();
}
}
}
}
Reported by PMD.
android/guava/src/com/google/common/cache/LongAdder.java
8 issues
Line: 44
*/
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
final class LongAdder extends Striped64 implements Serializable, LongAddable {
private static final long serialVersionUID = 7249069246863182397L;
/** Version of plus for use in retryUpdate */
@Override
final long fn(long v, long x) {
Reported by PMD.
Line: 68
int[] hc;
Cell a;
int n;
if ((as = cells) != null || !casBase(b = base, b + x)) {
boolean uncontended = true;
if ((hc = threadHashCode.get()) == null
|| as == null
|| (n = as.length) < 1
|| (a = as[(n - 1) & hc[0]]) == null
Reported by PMD.
Line: 70
int n;
if ((as = cells) != null || !casBase(b = base, b + x)) {
boolean uncontended = true;
if ((hc = threadHashCode.get()) == null
|| as == null
|| (n = as.length) < 1
|| (a = as[(n - 1) & hc[0]]) == null
|| !(uncontended = a.cas(v = a.value, v + x))) retryUpdate(x, hc, uncontended);
}
Reported by PMD.
Line: 191
private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException {
s.defaultReadObject();
busy = 0;
cells = null;
base = s.readLong();
}
}
Reported by PMD.
Line: 64
@Override
public void add(long x) {
Cell[] as;
long b, v;
int[] hc;
Cell a;
int n;
if ((as = cells) != null || !casBase(b = base, b + x)) {
boolean uncontended = true;
Reported by PMD.
Line: 68
int[] hc;
Cell a;
int n;
if ((as = cells) != null || !casBase(b = base, b + x)) {
boolean uncontended = true;
if ((hc = threadHashCode.get()) == null
|| as == null
|| (n = as.length) < 1
|| (a = as[(n - 1) & hc[0]]) == null
Reported by PMD.
Line: 69
Cell a;
int n;
if ((as = cells) != null || !casBase(b = base, b + x)) {
boolean uncontended = true;
if ((hc = threadHashCode.get()) == null
|| as == null
|| (n = as.length) < 1
|| (a = as[(n - 1) & hc[0]]) == null
|| !(uncontended = a.cas(v = a.value, v + x))) retryUpdate(x, hc, uncontended);
Reported by PMD.
Line: 70
int n;
if ((as = cells) != null || !casBase(b = base, b + x)) {
boolean uncontended = true;
if ((hc = threadHashCode.get()) == null
|| as == null
|| (n = as.length) < 1
|| (a = as[(n - 1) & hc[0]]) == null
|| !(uncontended = a.cas(v = a.value, v + x))) retryUpdate(x, hc, uncontended);
}
Reported by PMD.
android/guava/src/com/google/common/graph/ImmutableNetwork.java
8 issues
Line: 87
for (N node : network.nodes()) {
nodeConnections.put(node, connectionsOf(network, node));
}
return nodeConnections.build();
}
private static <N, E> Map<E, N> getEdgeToReferenceNode(Network<N, E> network) {
// ImmutableMap.Builder maintains the order of the elements as inserted, so the map will have
// whatever ordering the network's edges do, so ImmutableSortedMap is unnecessary even if the
Reported by PMD.
Line: 96
// input edges are sorted.
ImmutableMap.Builder<E, N> edgeToReferenceNode = ImmutableMap.builder();
for (E edge : network.edges()) {
edgeToReferenceNode.put(edge, network.incidentNodes(edge).nodeU());
}
return edgeToReferenceNode.build();
}
private static <N, E> NetworkConnections<N, E> connectionsOf(Network<N, E> network, N node) {
Reported by PMD.
Line: 98
for (E edge : network.edges()) {
edgeToReferenceNode.put(edge, network.incidentNodes(edge).nodeU());
}
return edgeToReferenceNode.build();
}
private static <N, E> NetworkConnections<N, E> connectionsOf(Network<N, E> network, N node) {
if (network.isDirected()) {
Map<E, N> inEdgeMap = Maps.asMap(network.inEdges(node), sourceNodeFn(network));
Reported by PMD.
Line: 105
if (network.isDirected()) {
Map<E, N> inEdgeMap = Maps.asMap(network.inEdges(node), sourceNodeFn(network));
Map<E, N> outEdgeMap = Maps.asMap(network.outEdges(node), targetNodeFn(network));
int selfLoopCount = network.edgesConnecting(node, node).size();
return network.allowsParallelEdges()
? DirectedMultiNetworkConnections.ofImmutable(inEdgeMap, outEdgeMap, selfLoopCount)
: DirectedNetworkConnections.ofImmutable(inEdgeMap, outEdgeMap, selfLoopCount);
} else {
Map<E, N> incidentEdgeMap =
Reported by PMD.
Line: 122
return new Function<E, N>() {
@Override
public N apply(E edge) {
return network.incidentNodes(edge).source();
}
};
}
private static <N, E> Function<E, N> targetNodeFn(final Network<N, E> network) {
Reported by PMD.
Line: 131
return new Function<E, N>() {
@Override
public N apply(E edge) {
return network.incidentNodes(edge).target();
}
};
}
private static <N, E> Function<E, N> adjacentNodeFn(final Network<N, E> network, final N node) {
Reported by PMD.
Line: 140
return new Function<E, N>() {
@Override
public N apply(E edge) {
return network.incidentNodes(edge).adjacentNode(node);
}
};
}
/**
Reported by PMD.
Line: 170
*/
public static class Builder<N, E> {
private final MutableNetwork<N, E> mutableNetwork;
Builder(NetworkBuilder<N, E> networkBuilder) {
this.mutableNetwork = networkBuilder.build();
}
Reported by PMD.