diff options
author | Marek Gradzki <mgradzki@cisco.com> | 2016-06-02 13:23:39 +0200 |
---|---|---|
committer | Marek Gradzki <mgradzki@cisco.com> | 2016-06-06 12:52:33 +0000 |
commit | 2da2d410e5bd679b356b079972b441695c353833 (patch) | |
tree | 606c630e72af772aedfbe48a67c8d8dc28206718 /v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterfaceUtils.java | |
parent | f6df9d5f3456e8bd2c355a9ae852ef2ecf75e6b5 (diff) |
Intializers for the new vlan model
Change-Id: I513f0b190e9d9e669663a9a216e7c72b1ebeb10d
Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
Diffstat (limited to 'v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterfaceUtils.java')
-rw-r--r-- | v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterfaceUtils.java | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterfaceUtils.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterfaceUtils.java index e0bae975f..756b298bd 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterfaceUtils.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterfaceUtils.java @@ -19,14 +19,15 @@ package io.fd.honeycomb.v3po.translate.v3po.interfacesstate; import static com.google.common.base.Preconditions.checkNotNull; import static io.fd.honeycomb.v3po.translate.v3po.interfacesstate.InterfaceCustomizer.getCachedInterfaceDump; import static java.util.Objects.requireNonNull; -import static java.util.stream.Collectors.toList; import com.google.common.base.Preconditions; import io.fd.honeycomb.v3po.translate.ModificationCache; +import io.fd.honeycomb.v3po.translate.util.RWUtils; import io.fd.honeycomb.v3po.translate.v3po.util.TranslateUtils; import java.math.BigInteger; import java.util.Map; import java.util.concurrent.CompletionStage; +import java.util.stream.Collector; import java.util.stream.Collectors; import javax.annotation.Nonnull; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.EthernetCsmacd; @@ -59,6 +60,9 @@ public final class InterfaceUtils { private static final int PHYSICAL_ADDRESS_LENGTH = 6; + private static final Collector<SwInterfaceDetails, ?, SwInterfaceDetails> SINGLE_ITEM_COLLECTOR = + RWUtils.singleItemCollector(); + private InterfaceUtils() { throw new UnsupportedOperationException("This utility class cannot be instantiated"); } @@ -147,11 +151,11 @@ public final class InterfaceUtils { /** * Queries VPP for interface description given interface key. * - * @param futureJvpp VPP Java Future API - * @param name interface name - * @param index VPP index of the interface - * @param ctx per-tx scope context containing cached dump with all the interfaces. If the cache is not - * available or outdated, another dump will be performed. + * @param futureJvpp VPP Java Future API + * @param name interface name + * @param index VPP index of the interface + * @param ctx per-tx scope context containing cached dump with all the interfaces. If the cache is not + * available or outdated, another dump will be performed. * @return SwInterfaceDetails DTO or null if interface was not found * @throws IllegalArgumentException If interface cannot be found */ @@ -198,13 +202,8 @@ public final class InterfaceUtils { } // SwInterfaceDump's name filter does prefix match, so we need additional filtering: - final SwInterfaceDetails iface = ifaces.swInterfaceDetails.stream().filter(d -> d.swIfIndex == index).collect( - Collectors.collectingAndThen(toList(), l -> { - if (l.size() == 1) { - return l.get(0); - } - throw new RuntimeException(); - })); + final SwInterfaceDetails iface = + ifaces.swInterfaceDetails.stream().filter(d -> d.swIfIndex == index).collect(SINGLE_ITEM_COLLECTOR); allInterfaces.put(index, iface); // update the cache return iface; } |