Replace anonymous classes with lambdas

Change-Id: Ia50a1a6a8f7de93941702878b9b9966a565deec8
This commit is contained in:
Dave Borowitz
2019-01-02 10:58:37 -08:00
parent 30b00a9f15
commit 4e4cdfe2ea
69 changed files with 248 additions and 732 deletions

View File

@@ -16,7 +16,6 @@ package com.google.gerrit.index;
import static com.google.common.base.Preconditions.checkState;
import com.google.common.base.Function;
import com.google.common.base.MoreObjects;
import com.google.common.base.Predicates;
import com.google.common.collect.FluentIterable;
@@ -176,24 +175,21 @@ public class Schema<T> {
public final Iterable<Values<T>> buildFields(T obj) {
return FluentIterable.from(fields.values())
.transform(
new Function<FieldDef<T, ?>, Values<T>>() {
@Override
public Values<T> apply(FieldDef<T, ?> f) {
Object v;
try {
v = f.get(obj);
} catch (OrmException e) {
logger.atSevere().withCause(e).log(
"error getting field %s of %s", f.getName(), obj);
return null;
}
if (v == null) {
return null;
} else if (f.isRepeatable()) {
return new Values<>(f, (Iterable<?>) v);
} else {
return new Values<>(f, Collections.singleton(v));
}
f -> {
Object v;
try {
v = f.get(obj);
} catch (OrmException e) {
logger.atSevere().withCause(e).log(
"error getting field %s of %s", f.getName(), obj);
return null;
}
if (v == null) {
return null;
} else if (f.isRepeatable()) {
return new Values<>(f, (Iterable<?>) v);
} else {
return new Values<>(f, Collections.singleton(v));
}
})
.filter(Predicates.notNull());