From 4e6b846c342b2c9e9443e3d3472685e5acb32fa3 Mon Sep 17 00:00:00 2001 From: Maros Marsalek Date: Wed, 13 Jul 2016 11:52:51 +0200 Subject: HONEYCOMB-122 Update reader registry to share similar APIs as writer + Extract common registry builder base code (Reader registry is not flat, so there is not full control over ordering as with writers but it is sufficient) + Split CompositeReader into CompositeReader, SubtreeReader and GenericReader + No need to build composite structure in ReaderFactories (registry does that internally) + Keep only ReaderCustomizer + ListReaderCustomizer, no root reader (same for writers) Change-Id: Ic4e5bc96ad47a6cbcada4efcc2209db5c16d2a6c Signed-off-by: Maros Marsalek --- .../fd/honeycomb/v3po/translate/util/RWUtils.java | 35 ++-------------------- 1 file changed, 3 insertions(+), 32 deletions(-) (limited to 'v3po/translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/util/RWUtils.java') diff --git a/v3po/translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/util/RWUtils.java b/v3po/translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/util/RWUtils.java index 55ae9ecf0..ba9d8e16f 100644 --- a/v3po/translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/util/RWUtils.java +++ b/v3po/translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/util/RWUtils.java @@ -22,7 +22,6 @@ import com.google.common.base.Predicate; import com.google.common.collect.Iterables; import com.google.common.collect.Maps; import io.fd.honeycomb.v3po.translate.SubtreeManager; -import io.fd.honeycomb.v3po.translate.read.ChildReader; import java.util.Collection; import java.util.Collections; import java.util.List; @@ -32,7 +31,6 @@ import java.util.stream.Collectors; import java.util.stream.StreamSupport; import javax.annotation.Nonnull; import org.opendaylight.yangtools.yang.binding.Augmentation; -import org.opendaylight.yangtools.yang.binding.ChildOf; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.Identifiable; import org.opendaylight.yangtools.yang.binding.Identifier; @@ -75,24 +73,6 @@ public final class RWUtils { return Iterables.get(pathArguments, i + 1); } - public static List>> emptyChildReaderList() { - return Collections.emptyList(); - } - - public static List>> emptyAugReaderList() { - return Collections.emptyList(); - } - - public static List>> singletonAugReaderList( - ChildReader> item) { - return Collections.>>singletonList(item); - } - - public static List>> singletonChildReaderList( - ChildReader> item) { - return Collections.>>singletonList(item); - } - /** * Replace last item in ID with a provided IdentifiableItem of the same type */ @@ -170,25 +150,16 @@ public final class RWUtils { } }; - @SuppressWarnings("unchecked") - public static InstanceIdentifier appendTypeToId( - final InstanceIdentifier parentId, final InstanceIdentifier type) { - Preconditions.checkArgument(!parentId.contains(type), - "Unexpected InstanceIdentifier %s, already contains %s", parentId, type); - final InstanceIdentifier.PathArgument t = Iterables.getOnlyElement(type.getPathArguments()); - return (InstanceIdentifier) InstanceIdentifier.create(Iterables.concat( - parentId.getPathArguments(), Collections.singleton(t))); - } - /** * Transform a keyed instance identifier into a wildcarded one. */ - public static InstanceIdentifier makeIidWildcarded(final InstanceIdentifier id) { + @SuppressWarnings("unchecked") + public static InstanceIdentifier makeIidWildcarded(final InstanceIdentifier id) { final List transformedPathArguments = StreamSupport.stream(id.getPathArguments().spliterator(), false) .map(RWUtils::cleanPathArgumentFromKeys) .collect(Collectors.toList()); - return InstanceIdentifier.create(transformedPathArguments); + return (InstanceIdentifier) InstanceIdentifier.create(transformedPathArguments); } private static InstanceIdentifier.PathArgument cleanPathArgumentFromKeys(final InstanceIdentifier.PathArgument pathArgument) { -- cgit 1.2.3-korg