*/
package org.opendaylight.mdsal.binding.dom.codec.impl;
-import com.google.common.base.Optional;
import com.google.common.collect.ImmutableCollection;
import com.google.common.collect.ImmutableSet;
import java.io.IOException;
import java.util.List;
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
+import java.util.Optional;
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeCachingCodec;
import org.opendaylight.yangtools.yang.binding.BindingStreamEventWriter;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.DataObjectSerializer;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.common.QNameModule;
import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter;
import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNormalizedNodeStreamWriter;
import org.opendaylight.yangtools.yang.data.impl.schema.NormalizedNodeResult;
+import org.opendaylight.yangtools.yang.model.api.DocumentedNode.WithStatus;
-abstract class DataContainerCodecContext<D extends DataObject,T> extends NodeCodecContext<D> {
+abstract class DataContainerCodecContext<D extends DataObject, T extends WithStatus> extends NodeCodecContext<D> {
private final DataContainerCodecPrototype<T> prototype;
private volatile DataObjectSerializer eventStreamSerializer;
return prototype.getSchema();
}
+ @Override
+ public final ChildAddressabilitySummary getChildAddressabilitySummary() {
+ return prototype.getChildAddressabilitySummary();
+ }
+
protected final QNameModule namespace() {
return prototype.getNamespace();
}
}
/**
- * Returns nested node context using supplied YANG Instance Identifier
+ * Returns nested node context using supplied YANG Instance Identifier.
*
* @param arg Yang Instance Identifier Argument
* @return Context of child
* @throws IllegalArgumentException If supplied argument does not represent valid child.
*/
@Override
- public abstract NodeCodecContext<?> yangPathArgumentChild(final YangInstanceIdentifier.PathArgument arg);
+ public abstract NodeCodecContext<?> yangPathArgumentChild(YangInstanceIdentifier.PathArgument arg);
/**
* Returns nested node context using supplied Binding Instance Identifier
* @throws IllegalArgumentException If supplied argument does not represent valid child.
*/
@Override
- public @Nullable DataContainerCodecContext<?,?> bindingPathArgumentChild(final InstanceIdentifier.PathArgument arg,
+ public DataContainerCodecContext<?, ?> bindingPathArgumentChild(final PathArgument arg,
final List<YangInstanceIdentifier.PathArgument> builder) {
final DataContainerCodecContext<?,?> child = streamChild(arg.getType());
- if(child != null) {
- if (builder != null) {
- child.addYangPathArgument(arg,builder);
- }
- return child;
+ if (builder != null) {
+ child.addYangPathArgument(arg,builder);
}
- throw new IllegalArgumentException("SUpplied argument is not valid child");
+ return child;
}
/**
* Returns deserialized Binding Path Argument from YANG instance identifier.
- *
- * @param domArg
- * @return
*/
protected PathArgument getBindingPathArgument(final YangInstanceIdentifier.PathArgument domArg) {
return bindingArg();
return Class.class.cast(prototype.getBindingClass());
}
- /**
- *
- * Returns child context as if it was walked by
- * {@link BindingStreamEventWriter}. This means that to enter case, one
- * must issue getChild(ChoiceClass).getChild(CaseClass).
- *
- * @param childClass
- * @return Context of child node or null, if supplied class is not subtree child
- * @throws IllegalArgumentException If supplied child class is not valid in specified context.
- */
@Override
- public abstract @Nullable <DV extends DataObject> DataContainerCodecContext<DV,?> streamChild(final Class<DV> childClass) throws IllegalArgumentException;
+ public abstract <C extends DataObject> DataContainerCodecContext<C, ?> streamChild(Class<C> childClass);
/**
- *
- * Returns child context as if it was walked by
- * {@link BindingStreamEventWriter}. This means that to enter case, one
+ * Returns child context as if it was walked by {@link BindingStreamEventWriter}. This means that to enter case, one
* must issue getChild(ChoiceClass).getChild(CaseClass).
*
- * @param childClass
- * @return Context of child or Optional absent is supplied class is not applicable in context.
+ * @param childClass child class
+ * @return Context of child or Optional.empty is supplied class is not applicable in context.
*/
@Override
- public abstract <DV extends DataObject> Optional<DataContainerCodecContext<DV,?>> possibleStreamChild(final Class<DV> childClass);
+ public abstract <C extends DataObject> Optional<DataContainerCodecContext<C,?>> possibleStreamChild(
+ Class<C> childClass);
@Override
public String toString() {
@Override
public BindingNormalizedNodeCachingCodec<D> createCachingCodec(
final ImmutableCollection<Class<? extends DataObject>> cacheSpecifier) {
- if(cacheSpecifier.isEmpty()) {
+ if (cacheSpecifier.isEmpty()) {
return new NonCachingCodec<>(this);
}
return new CachingNormalizedNodeCodec<>(this,ImmutableSet.copyOf(cacheSpecifier));
return BindingToNormalizedStreamWriter.create(this, domWriter);
}
- @Nonnull
- protected final <V> V childNonNull(@Nullable final V nullable, final YangInstanceIdentifier.PathArgument child,
- final String message, final Object... args) {
+ protected final <V> @NonNull V childNonNull(final @Nullable V nullable,
+ final YangInstanceIdentifier.PathArgument child, final String message, final Object... args) {
if (nullable != null) {
return nullable;
}
throw IncorrectNestingException.create(message, args);
}
- @Nonnull
- protected final <V> V childNonNull(@Nullable final V nullable, final QName child, final String message,
+ protected final <V> @NonNull V childNonNull(final @Nullable V nullable, final QName child, final String message,
final Object... args) {
if (nullable != null) {
return nullable;
throw IncorrectNestingException.create(message, args);
}
- @Nonnull
- protected final <V> V childNonNull(@Nullable final V nullable, final Class<?> childClass, final String message,
- final Object... args) {
+ protected final <V> @NonNull V childNonNull(final @Nullable V nullable, final Class<?> childClass,
+ final String message, final Object... args) {
if (nullable != null) {
return nullable;
}
}
DataObjectSerializer eventStreamSerializer() {
- if(eventStreamSerializer == null) {
+ if (eventStreamSerializer == null) {
eventStreamSerializer = factory().getEventStreamSerializer(getBindingClass());
}
return eventStreamSerializer;
throw new IllegalStateException("Failed to serialize Binding DTO",e);
}
}
-
-}
\ No newline at end of file
+}