summaryrefslogtreecommitdiffstats
path: root/infra/translate-impl/src/main/java
diff options
context:
space:
mode:
authorJan Srnicek <jsrnicek@cisco.com>2017-02-07 09:33:38 +0100
committerJan Srnicek <jsrnicek@cisco.com>2017-02-07 09:33:38 +0100
commit8450b69800c827ba221351eb0c374fcbd9146593 (patch)
tree8b53ec074196bedd2b4012d69dda60fb756bfa64 /infra/translate-impl/src/main/java
parent92afaeb4a959ea5a6a072fe3ed7a01088d703e0b (diff)
Prevent submitting of structural reader for list node
Static customizer must be provided instead till HONEYCOMB-344 is resolved Change-Id: Id71f69fe23b156e6de10eed06a3596de8e602bbe Signed-off-by: Jan Srnicek <jsrnicek@cisco.com>
Diffstat (limited to 'infra/translate-impl/src/main/java')
-rw-r--r--infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/read/registry/CompositeReaderRegistryBuilder.java12
1 files changed, 11 insertions, 1 deletions
diff --git a/infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/read/registry/CompositeReaderRegistryBuilder.java b/infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/read/registry/CompositeReaderRegistryBuilder.java
index 36ab90995..dd6a838c6 100644
--- a/infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/read/registry/CompositeReaderRegistryBuilder.java
+++ b/infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/read/registry/CompositeReaderRegistryBuilder.java
@@ -25,18 +25,23 @@ import io.fd.honeycomb.translate.read.registry.ModifiableReaderRegistryBuilder;
import io.fd.honeycomb.translate.read.registry.ReaderRegistry;
import io.fd.honeycomb.translate.read.registry.ReaderRegistryBuilder;
import io.fd.honeycomb.translate.util.AbstractSubtreeManagerRegistryBuilderBuilder;
+
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import javax.annotation.Nonnull;
import javax.annotation.concurrent.NotThreadSafe;
+
import org.opendaylight.yangtools.concepts.Builder;
import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.Identifiable;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import static com.google.common.base.Preconditions.checkArgument;
+
@NotThreadSafe
public final class CompositeReaderRegistryBuilder
extends AbstractSubtreeManagerRegistryBuilderBuilder<Reader<? extends DataObject, ? extends Builder<?>>, ReaderRegistry>
@@ -48,13 +53,18 @@ public final class CompositeReaderRegistryBuilder
protected Reader<? extends DataObject, ? extends Builder<?>> getSubtreeHandler(@Nonnull final Set<InstanceIdentifier<?>> handledChildren,
@Nonnull final Reader<? extends DataObject, ? extends Builder<?>> reader) {
return reader instanceof Initializer
- ? InitSubtreeReader.createForReader(handledChildren, (InitReader<?, ?>)reader)
+ ? InitSubtreeReader.createForReader(handledChildren, (InitReader<?, ?>) reader)
: SubtreeReader.createForReader(handledChildren, reader);
}
@Override
public <D extends DataObject> void addStructuralReader(@Nonnull InstanceIdentifier<D> id,
@Nonnull Class<? extends Builder<D>> builderType) {
+ // TODO https://jira.fd.io/browse/HONEYCOMB-344 provide variant of this method for list nodes
+ // prevent case to submit structural reader for list, which would cause fail because target setter consumes
+ // List<TargetType>, not Target type. If node is static, customizer that handles it should return static list
+ // of IDs.
+ checkArgument(!Identifiable.class.isAssignableFrom(id.getTargetType()), "Structural readers cannot be used for keyed nodes[node type %s]", id.getTargetType());
add(GenericReader.createReflexive(id, builderType));
}