From f7c5300c54fcb51f9bc763b8d5f43a882c4ed5b1 Mon Sep 17 00:00:00 2001 From: Marek Gradzki Date: Mon, 6 Aug 2018 08:24:21 +0200 Subject: RWUtils: use lambdas instead of anonymous inner classes Change-Id: Ie17b819efd381983754065a821771eb3aac11d06 Signed-off-by: Marek Gradzki --- .../io/fd/honeycomb/translate/util/RWUtils.java | 31 ++++------------------ 1 file changed, 5 insertions(+), 26 deletions(-) diff --git a/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/RWUtils.java b/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/RWUtils.java index 5b0a4919e..3e1582fd8 100644 --- a/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/RWUtils.java +++ b/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/RWUtils.java @@ -18,7 +18,6 @@ package io.fd.honeycomb.translate.util; import com.google.common.base.Function; import com.google.common.base.Preconditions; -import com.google.common.base.Predicate; import com.google.common.collect.Iterables; import com.google.common.collect.Maps; import io.fd.honeycomb.translate.SubtreeManager; @@ -64,12 +63,7 @@ public final class RWUtils { public static InstanceIdentifier.PathArgument getNextId(@Nonnull final InstanceIdentifier id, @Nonnull final InstanceIdentifier type) { final Iterable pathArguments = id.getPathArguments(); - final int i = Iterables.indexOf(pathArguments, new Predicate() { - @Override - public boolean apply(final InstanceIdentifier.PathArgument input) { - return input.getType().isAssignableFrom(type.getTargetType()); - } - }); + final int i = Iterables.indexOf(pathArguments, input -> input.getType().isAssignableFrom(type.getTargetType())); Preconditions.checkArgument(i >= 0, "Unable to find %s type in %s", type.getTargetType(), id); return Iterables.get(pathArguments, i + 1); } @@ -107,12 +101,7 @@ public final class RWUtils { public static InstanceIdentifier cutId(@Nonnull final InstanceIdentifier id, @Nonnull final InstanceIdentifier type) { final Iterable pathArguments = id.getPathArguments(); - final int i = Iterables.indexOf(pathArguments, new Predicate() { - @Override - public boolean apply(final InstanceIdentifier.PathArgument input) { - return input.getType().equals(type.getTargetType()); - } - }); + final int i = Iterables.indexOf(pathArguments, input -> input.getType().equals(type.getTargetType())); Preconditions.checkArgument(i >= 0, "ID %s does not contain %s", id, type); return (InstanceIdentifier) InstanceIdentifier.create(Iterables.limit(pathArguments, i + 1)); } @@ -141,24 +130,14 @@ public final class RWUtils { } public static final Function, Class> - MANAGER_CLASS_FUNCTION = new Function, Class>() { - @Override - public Class apply(final SubtreeManager input) { - return input.getManagedDataObjectType().getTargetType(); - } - }; + MANAGER_CLASS_FUNCTION = input -> input.getManagedDataObjectType().getTargetType(); public static final Function>, Class> - MANAGER_CLASS_AUG_FUNCTION = new Function>, Class>() { - - @Override - @SuppressWarnings("unchecked") - public Class apply(final SubtreeManager> input) { + MANAGER_CLASS_AUG_FUNCTION = input -> { final Class> targetType = input.getManagedDataObjectType().getTargetType(); Preconditions.checkArgument(DataObject.class.isAssignableFrom(targetType)); return (Class) targetType; - } - }; + }; /** * Transform a keyed instance identifier into a wildcarded one. -- cgit 1.2.3-korg