formatting cleanup

This commit is contained in:
eugenp 2016-01-24 19:54:57 +02:00
parent a25f807e3e
commit 8771311100
4 changed files with 22 additions and 19 deletions

View File

@ -6,12 +6,12 @@ import java.util.function.Function;
public class AdderImpl implements Adder {
@Override
public String addWithFunction(Function<String, String> f) {
public String addWithFunction(final Function<String, String> f) {
return f.apply("Something ");
}
@Override
public void addWithConsumer(Consumer<Integer> f) {
public void addWithConsumer(final Consumer<Integer> f) {
}
}

View File

@ -6,12 +6,12 @@ public class Computer {
private String color;
private Integer healty;
public Computer(int age, String color) {
public Computer(final int age, final String color) {
this.age = age;
this.color = color;
}
public Computer(Integer age, String color, Integer healty) {
public Computer(final Integer age, final String color, final Integer healty) {
this.age = age;
this.color = color;
this.healty = healty;
@ -24,7 +24,7 @@ public class Computer {
return age;
}
public void setAge(Integer age) {
public void setAge(final Integer age) {
this.age = age;
}
@ -32,7 +32,7 @@ public class Computer {
return color;
}
public void setColor(String color) {
public void setColor(final String color) {
this.color = color;
}
@ -40,7 +40,7 @@ public class Computer {
return healty;
}
public void setHealty(Integer healty) {
public void setHealty(final Integer healty) {
this.healty = healty;
}
@ -50,16 +50,19 @@ public class Computer {
}
@Override
public boolean equals(Object o) {
if (this == o)
public boolean equals(final Object o) {
if (this == o) {
return true;
if (o == null || getClass() != o.getClass())
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Computer computer = (Computer) o;
final Computer computer = (Computer) o;
if (age != null ? !age.equals(computer.age) : computer.age != null)
if (age != null ? !age.equals(computer.age) : computer.age != null) {
return false;
}
return color != null ? color.equals(computer.color) : computer.color == null;
}

View File

@ -1,24 +1,24 @@
package com.baeldung.doublecolumn;
import com.baeldung.doublecolumn.function.ComputerPredicate;
import java.util.ArrayList;
import java.util.List;
import com.baeldung.doublecolumn.function.ComputerPredicate;
public class ComputerUtils {
public static final ComputerPredicate after2010Predicate = (c) -> (c.getAge() > 2010);
public static final ComputerPredicate blackPredicate = (c) -> "black".equals(c.getColor());
public static List<Computer> filter(List<Computer> inventory, ComputerPredicate p) {
public static List<Computer> filter(final List<Computer> inventory, final ComputerPredicate p) {
List<Computer> result = new ArrayList<>();
final List<Computer> result = new ArrayList<>();
inventory.stream().filter(p::filter).forEach(result::add);
return result;
}
public static void repair(Computer computer) {
public static void repair(final Computer computer) {
if (computer.getHealty() < 50) {
computer.setHealty(100);
}

View File

@ -8,8 +8,8 @@ public interface TriFunction<A, B, C, R> {
R apply(A a, B b, C c);
default <V> TriFunction<A, B, C, V> andThen(Function<? super R, ? extends V> after) {
default <V> TriFunction<A, B, C, V> andThen(final Function<? super R, ? extends V> after) {
Objects.requireNonNull(after);
return (A a, B b, C c) -> after.apply(apply(a, b, c));
return (final A a, final B b, final C c) -> after.apply(apply(a, b, c));
}
}