diff options
author | Maros Marsalek <mmarsale@cisco.com> | 2016-06-29 09:14:51 +0200 |
---|---|---|
committer | Maros Marsalek <mmarsale@cisco.com> | 2016-07-13 11:24:26 +0200 |
commit | 9f6b16d6e8ade6dfa40e9bbf4196d55adf8f2fec (patch) | |
tree | 9cd3d971e42b9351fbba36c788631e7a68a1027d /v3po/translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/util/RWUtils.java | |
parent | 348d54eb9a762f1bde68ef8becb5d9e5a1ca7006 (diff) |
HONEYCOMB-94 Reimplement writer registry with better ordering options
Now the registry is flat and allows for full control of writer execution order
Change-Id: I864e1d676588ffe59b596145e0829e81b1a1ed2f
Signed-off-by: Maros Marsalek <mmarsale@cisco.com>
Diffstat (limited to 'v3po/translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/util/RWUtils.java')
-rw-r--r-- | v3po/translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/util/RWUtils.java | 37 |
1 files changed, 18 insertions, 19 deletions
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 b712e159c..55ae9ecf0 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 @@ -23,13 +23,13 @@ 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 io.fd.honeycomb.v3po.translate.write.ChildWriter; import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Map; import java.util.stream.Collector; 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; @@ -79,18 +79,10 @@ public final class RWUtils { return Collections.emptyList(); } - public static <T> List<ChildWriter<? extends ChildOf<T>>> emptyChildWriterList() { - return Collections.emptyList(); - } - public static <T> List<ChildReader<? extends Augmentation<T>>> emptyAugReaderList() { return Collections.emptyList(); } - public static <T> List<ChildWriter<? extends Augmentation<T>>> emptyAugWriterList() { - return Collections.emptyList(); - } - public static <T> List<ChildReader<? extends Augmentation<T>>> singletonAugReaderList( ChildReader<? extends Augmentation<T>> item) { return Collections.<ChildReader<? extends Augmentation<T>>>singletonList(item); @@ -101,16 +93,6 @@ public final class RWUtils { return Collections.<ChildReader<? extends ChildOf<T>>>singletonList(item); } - public static <T> List<ChildWriter<? extends ChildOf<T>>> singletonChildWriterList( - ChildWriter<? extends ChildOf<T>> item) { - return Collections.<ChildWriter<? extends ChildOf<T>>>singletonList(item); - } - - public static <T> List<ChildWriter<? extends Augmentation<T>>> singletonAugWriterList( - ChildWriter<? extends Augmentation<T>> item) { - return Collections.<ChildWriter<? extends Augmentation<T>>>singletonList(item); - } - /** * Replace last item in ID with a provided IdentifiableItem of the same type */ @@ -197,4 +179,21 @@ public final class RWUtils { return (InstanceIdentifier<D>) 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) { + final List<InstanceIdentifier.PathArgument> transformedPathArguments = + StreamSupport.stream(id.getPathArguments().spliterator(), false) + .map(RWUtils::cleanPathArgumentFromKeys) + .collect(Collectors.toList()); + return InstanceIdentifier.create(transformedPathArguments); + } + + private static InstanceIdentifier.PathArgument cleanPathArgumentFromKeys(final InstanceIdentifier.PathArgument pathArgument) { + return pathArgument instanceof InstanceIdentifier.IdentifiableItem<?, ?> + ? new InstanceIdentifier.Item<>(pathArgument.getType()) + : pathArgument; + } } |