Fix PMD violations #327
This commit is contained in:
@ -65,7 +65,7 @@ public class App {
|
||||
|
||||
List<String> lastTwoOfFirstFourStringMapped =
|
||||
LazyFluentIterable.from(integerList).filter(positives()).first(4).last(2)
|
||||
.map(number -> "String[" + String.valueOf(number) + "]").asList();
|
||||
.map(number -> "String[" + valueOf(number) + "]").asList();
|
||||
prettyPrint(
|
||||
"The lazy list contains the last two of the first four positive numbers mapped to Strings: ",
|
||||
lastTwoOfFirstFourStringMapped);
|
||||
@ -85,19 +85,19 @@ public class App {
|
||||
}
|
||||
|
||||
private static Predicate<? super Integer> negatives() {
|
||||
return integer -> (integer < 0);
|
||||
return integer -> integer < 0;
|
||||
}
|
||||
|
||||
private static Predicate<? super Integer> positives() {
|
||||
return integer -> (integer > 0);
|
||||
return integer -> integer > 0;
|
||||
}
|
||||
|
||||
private static <TYPE> void prettyPrint(String prefix, Iterable<TYPE> iterable) {
|
||||
prettyPrint(", ", prefix, ".", iterable);
|
||||
prettyPrint(", ", prefix, iterable);
|
||||
}
|
||||
|
||||
private static <TYPE> void prettyPrint(String delimiter, String prefix, String suffix,
|
||||
Iterable<TYPE> iterable) {
|
||||
private static <TYPE> void prettyPrint(String delimiter, String prefix,
|
||||
Iterable<TYPE> iterable) {
|
||||
StringJoiner joiner = new StringJoiner(delimiter, prefix, ".");
|
||||
Iterator<TYPE> iterator = iterable.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
|
@ -53,10 +53,9 @@ public class LazyFluentIterable<TYPE> implements FluentIterable<TYPE> {
|
||||
public TYPE computeNext() {
|
||||
while (fromIterator.hasNext()) {
|
||||
TYPE candidate = fromIterator.next();
|
||||
if (!predicate.test(candidate)) {
|
||||
continue;
|
||||
if (predicate.test(candidate)) {
|
||||
return candidate;
|
||||
}
|
||||
return candidate;
|
||||
}
|
||||
|
||||
return null;
|
||||
@ -94,12 +93,10 @@ public class LazyFluentIterable<TYPE> implements FluentIterable<TYPE> {
|
||||
|
||||
@Override
|
||||
public TYPE computeNext() {
|
||||
if (currentIndex < count) {
|
||||
if (fromIterator.hasNext()) {
|
||||
TYPE candidate = fromIterator.next();
|
||||
currentIndex++;
|
||||
return candidate;
|
||||
}
|
||||
if (currentIndex < count && fromIterator.hasNext()) {
|
||||
TYPE candidate = fromIterator.next();
|
||||
currentIndex++;
|
||||
return candidate;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -188,11 +185,12 @@ public class LazyFluentIterable<TYPE> implements FluentIterable<TYPE> {
|
||||
|
||||
@Override
|
||||
public NEW_TYPE computeNext() {
|
||||
while (oldTypeIterator.hasNext()) {
|
||||
if (oldTypeIterator.hasNext()) {
|
||||
TYPE candidate = oldTypeIterator.next();
|
||||
return function.apply(candidate);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -2,8 +2,6 @@ package com.iluwatar.fluentinterface.app;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.iluwatar.fluentinterface.app.App;
|
||||
|
||||
public class AppTest {
|
||||
|
||||
@Test
|
||||
|
@ -2,21 +2,11 @@ package com.iluwatar.fluentinterface.fluentiterable;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Spliterator;
|
||||
import java.util.*;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
/**
|
||||
* Date: 12/12/15 - 7:00 PM
|
||||
|
Reference in New Issue
Block a user