Run automatic Java 8 conversion over codebase

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=171174380
This commit is contained in:
mcilwain 2017-10-05 10:48:38 -07:00 committed by Ben McIlwain
parent 44df5da771
commit 5edb7935ed
190 changed files with 2312 additions and 3096 deletions

View file

@ -14,9 +14,10 @@
package google.registry.model;
import com.google.common.base.Function;
import static com.google.common.collect.ImmutableList.toImmutableList;
import com.google.common.base.Functions;
import com.google.common.collect.FluentIterable;
import com.google.common.collect.Streams;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
@ -29,14 +30,6 @@ import javax.annotation.Nullable;
* list is passed as {@code null}, it'll be substituted with empty list. Lists are not mutable.
*/
public final class JsonMapBuilder {
private static final Function<Jsonifiable, Map<String, Object>> TO_JSON_OBJECT =
new Function<Jsonifiable, Map<String, Object>>() {
@Override
public Map<String, Object> apply(Jsonifiable input) {
return input.toJsonMap();
}};
private final Map<String, Object> map = new LinkedHashMap<>();
public JsonMapBuilder put(String name, @Nullable Boolean value) {
@ -70,15 +63,21 @@ public final class JsonMapBuilder {
}
public <T> JsonMapBuilder putListOfStrings(String name, @Nullable Iterable<T> value) {
map.put(name, value == null ? Collections.EMPTY_LIST
: FluentIterable.from(value).transform(Functions.toStringFunction()).toList());
map.put(
name,
value == null
? Collections.EMPTY_LIST
: Streams.stream(value).map(Functions.toStringFunction()).collect(toImmutableList()));
return this;
}
public JsonMapBuilder putListOfJsonObjects(
String name, @Nullable Iterable<? extends Jsonifiable> value) {
map.put(name, value == null ? Collections.EMPTY_LIST
: FluentIterable.from(value).transform(TO_JSON_OBJECT).toList());
map.put(
name,
value == null
? Collections.EMPTY_LIST
: Streams.stream(value).map(Jsonifiable::toJsonMap).collect(toImmutableList()));
return this;
}