Fix checkstyle violations (tabs, missing spaces after commas, missing javadocs)

This commit is contained in:
Bruno P. Kinoshita 2019-08-25 13:09:20 +12:00
parent 102a6d7565
commit 26bc45fdee
2 changed files with 137 additions and 92 deletions

View File

@ -144,6 +144,9 @@ public class Functions {
/**
* Converts the given {@link FailableRunnable} into a standard {@link Runnable}.
*
* @param pRunnable a {@code FailableRunnable}
* @return a standard {@code Runnable}
*/
public static Runnable asRunnable(FailableRunnable<?> pRunnable) {
return () -> {
@ -157,8 +160,12 @@ public class Functions {
/**
* Converts the given {@link FailableConsumer} into a standard {@link Consumer}.
*
* @param <I> the type used by the consumers
* @param pConsumer a {@code FailableConsumer}
* @return a standard {@code Consumer}
*/
public static <I> Consumer<I> asConsumer(FailableConsumer<I,?> pConsumer) {
public static <I> Consumer<I> asConsumer(FailableConsumer<I, ?> pConsumer) {
return (pInput) -> {
try {
pConsumer.accept(pInput);
@ -170,8 +177,12 @@ public class Functions {
/**
* Converts the given {@link FailableCallable} into a standard {@link Callable}.
*
* @param <O> the type used by the callables
* @param pCallable a {@code FailableCallable}
* @return a standard {@code Callable}
*/
public static <O> Callable<O> asCallable(FailableCallable<O,?> pCallable) {
public static <O> Callable<O> asCallable(FailableCallable<O, ?> pCallable) {
return () -> {
try {
return pCallable.call();
@ -183,8 +194,13 @@ public class Functions {
/**
* Converts the given {@link FailableBiConsumer} into a standard {@link BiConsumer}.
*
* @param <I1> the type of the first argument of the consumers
* @param <I2> the type of the second argument of the consumers
* @param pConsumer a failable {@code BiConsumer}
* @return a standard {@code BiConsumer}
*/
public static <I1,I2> BiConsumer<I1,I2> asBiConsumer(FailableBiConsumer<I1,I2,?> pConsumer) {
public static <I1, I2> BiConsumer<I1, I2> asBiConsumer(FailableBiConsumer<I1, I2, ?> pConsumer) {
return (pInput1, pInput2) -> {
try {
pConsumer.accept(pInput1, pInput2);
@ -196,8 +212,13 @@ public class Functions {
/**
* Converts the given {@link FailableFunction} into a standard {@link Function}.
*
* @param <I> the type of the input of the functions
* @param <O> the type of the output of the functions
* @param pFunction a {code FailableFunction}
* @return a standard {@code Function}
*/
public static <I,O> Function<I,O> asFunction(FailableFunction<I,O,?> pFunction) {
public static <I, O> Function<I, O> asFunction(FailableFunction<I, O, ?> pFunction) {
return (pInput) -> {
try {
return pFunction.apply(pInput);
@ -209,8 +230,14 @@ public class Functions {
/**
* Converts the given {@link FailableBiFunction} into a standard {@link BiFunction}.
*
* @param <I1> the type of the first argument of the input of the functions
* @param <I2> the type of the second argument of the input of the functions
* @param <O> the type of the output of the functions
* @param pFunction a {@code FailableBiFunction}
* @return a standard {@code BiFunction}
*/
public static <I1,I2,O> BiFunction<I1,I2,O> asBiFunction(FailableBiFunction<I1,I2,O,?> pFunction) {
public static <I1, I2, O> BiFunction<I1, I2, O> asBiFunction(FailableBiFunction<I1, I2, O, ?> pFunction) {
return (pInput1, pInput2) -> {
try {
return pFunction.apply(pInput1, pInput2);
@ -222,8 +249,12 @@ public class Functions {
/**
* Converts the given {@link FailablePredicate} into a standard {@link Predicate}.
*
* @param <I> the type used by the predicates
* @param pPredicate a {@code FailablePredicate}
* @return a standard {@code Predicate}
*/
public static <I> Predicate<I> asPredicate(FailablePredicate<I,?> pPredicate) {
public static <I> Predicate<I> asPredicate(FailablePredicate<I, ?> pPredicate) {
return (pInput) -> {
try {
return pPredicate.test(pInput);
@ -235,8 +266,13 @@ public class Functions {
/**
* Converts the given {@link FailableBiPredicate} into a standard {@link BiPredicate}.
*
* @param <I1> the type of the first argument used by the predicates
* @param <I2> the type of the second argument used by the predicates
* @param pPredicate a {@code FailableBiPredicate}
* @return a standard {@code BiPredicate}
*/
public static <I1,I2> BiPredicate<I1,I2> asBiPredicate(FailableBiPredicate<I1,I2,?> pPredicate) {
public static <I1, I2> BiPredicate<I1, I2> asBiPredicate(FailableBiPredicate<I1, I2, ?> pPredicate) {
return (pInput1, pInput2) -> {
try {
return pPredicate.test(pInput1, pInput2);
@ -248,8 +284,12 @@ public class Functions {
/**
* Converts the given {@link FailableSupplier} into a standard {@link Supplier}.
*
* @param <O> the type supplied by the suppliers
* @param pSupplier a {@code FailableSupplier}
* @return a standard {@code Supplier}
*/
public static <O> Supplier<O> asSupplier(FailableSupplier<O,?> pSupplier) {
public static <O> Supplier<O> asSupplier(FailableSupplier<O, ?> pSupplier) {
return () -> {
try {
return pSupplier.get();
@ -396,7 +436,7 @@ public class Functions {
* @param <T> The type of checked exception, which the supplier can throw.
* @return The object, which has been created by the supplier
*/
public static <O,T extends Throwable> O get(FailableSupplier<O,T> pSupplier) {
public static <O, T extends Throwable> O get(FailableSupplier<O, T> pSupplier) {
try {
return pSupplier.get();
} catch (Throwable t) {

View File

@ -39,7 +39,6 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.assertFalse;
class FunctionsTest {
public static class SomeException extends Exception {
@ -168,7 +167,9 @@ class FunctionsTest {
@Test
void testAsCallable() {
FailureOnOddInvocations.invocation = 0;
final FailableCallable<FailureOnOddInvocations,SomeException> failableCallable = () -> { return new FailureOnOddInvocations(); };
final FailableCallable<FailureOnOddInvocations, SomeException> failableCallable = () -> {
return new FailureOnOddInvocations();
};
final Callable<FailureOnOddInvocations> callable = Functions.asCallable(failableCallable);
UndeclaredThrowableException e = assertThrows(UndeclaredThrowableException.class, () -> callable.call());
final Throwable cause = e.getCause();
@ -257,7 +258,9 @@ class FunctionsTest {
void testAsBiConsumer() {
final IllegalStateException ise = new IllegalStateException();
final Testable testable = new Testable(null);
final FailableBiConsumer<Testable, Throwable, Throwable> failableBiConsumer = (t, th) -> { t.setThrowable(th); t.test(); };
final FailableBiConsumer<Testable, Throwable, Throwable> failableBiConsumer = (t, th) -> {
t.setThrowable(th); t.test();
};
final BiConsumer<Testable, Throwable> consumer = Functions.asBiConsumer(failableBiConsumer);
Throwable e = assertThrows(IllegalStateException.class, () -> consumer.accept(testable, ise));
assertSame(ise, e);
@ -305,11 +308,11 @@ class FunctionsTest {
public void testAsFunction() {
final IllegalStateException ise = new IllegalStateException();
final Testable testable = new Testable(ise);
final FailableFunction<Throwable,Integer,Throwable> failableFunction = (th) -> {
final FailableFunction<Throwable, Integer, Throwable> failableFunction = (th) -> {
testable.setThrowable(th);
return Integer.valueOf(testable.testInt());
};
final Function<Throwable,Integer> function = Functions.asFunction(failableFunction);
final Function<Throwable, Integer> function = Functions.asFunction(failableFunction);
Throwable e = assertThrows(IllegalStateException.class, () -> function.apply(ise));
assertSame(ise, e);
@ -354,11 +357,11 @@ class FunctionsTest {
public void testAsBiFunction() {
final IllegalStateException ise = new IllegalStateException();
final Testable testable = new Testable(ise);
final FailableBiFunction<Testable,Throwable,Integer,Throwable> failableBiFunction = (t, th) -> {
final FailableBiFunction<Testable, Throwable, Integer, Throwable> failableBiFunction = (t, th) -> {
t.setThrowable(th);
return Integer.valueOf(t.testInt());
};
final BiFunction<Testable,Throwable,Integer> biFunction = Functions.asBiFunction(failableBiFunction);
final BiFunction<Testable, Throwable, Integer> biFunction = Functions.asBiFunction(failableBiFunction);
Throwable e = assertThrows(IllegalStateException.class, () -> biFunction.apply(testable, ise));
assertSame(ise, e);
@ -392,7 +395,9 @@ class FunctionsTest {
@Test
public void testAsSupplier() {
FailureOnOddInvocations.invocation = 0;
final FailableSupplier<FailureOnOddInvocations,Throwable> failableSupplier = () -> { return new FailureOnOddInvocations(); };
final FailableSupplier<FailureOnOddInvocations, Throwable> failableSupplier = () -> {
return new FailureOnOddInvocations();
};
final Supplier<FailureOnOddInvocations> supplier = Functions.asSupplier(failableSupplier);
UndeclaredThrowableException e = assertThrows(UndeclaredThrowableException.class, () -> supplier.get());
final Throwable cause = e.getCause();