class BindingToNormalizedStreamWriter implements BindingStreamEventWriter, Delegator<NormalizedNodeStreamWriter> {
private final NormalizedNodeStreamWriter delegate;
- private final Deque<NodeCodecContext> schema = new ArrayDeque<>();
- private final NodeCodecContext rootNodeSchema;
+ private final Deque<NodeCodecContext<?>> schema = new ArrayDeque<>();
+ private final NodeCodecContext<?> rootNodeSchema;
- public BindingToNormalizedStreamWriter(final NodeCodecContext schema, final NormalizedNodeStreamWriter delegate) {
+ public BindingToNormalizedStreamWriter(final NodeCodecContext<?> schema, final NormalizedNodeStreamWriter delegate) {
this.delegate = Preconditions.checkNotNull(delegate, "Delegate must not be null");
this.rootNodeSchema = Preconditions.checkNotNull(schema);
}
- private NodeCodecContext current() {
+ private NodeCodecContext<?> current() {
return schema.peek();
}
private NodeIdentifier duplicateSchemaEnter() {
- final NodeCodecContext next;
+ final NodeCodecContext<?> next;
if (current() == null) {
// Entry of first node
next = rootNodeSchema;
return (NodeIdentifier) current().getDomPathArgument();
}
+ @SuppressWarnings({"unchecked", "rawtypes"})
private <T extends YangInstanceIdentifier.PathArgument> T enter(final Class<?> name, final Class<T> identifier) {
- final NodeCodecContext next;
+ final NodeCodecContext<?> next;
if (current() == null) {
// Entry of first node
next = rootNodeSchema;
} else {
Preconditions.checkArgument((current() instanceof DataContainerCodecContext), "Could not start node %s",
name);
- next = ((DataContainerCodecContext<?>) current()).getStreamChild(name);
+ next = ((DataContainerCodecContext<?,?>) current()).streamChild((Class) name);
}
this.schema.push(next);
- @SuppressWarnings("unchecked")
T arg = (T) next.getDomPathArgument();
return arg;
}
private <T extends YangInstanceIdentifier.PathArgument> T enter(final String localName, final Class<T> identifier) {
- NodeCodecContext current = current();
- NodeCodecContext next = ((DataObjectCodecContext<?>) current).getLeafChild(localName);
+ NodeCodecContext<?> current = current();
+ NodeCodecContext<?> next = ((DataObjectCodecContext<?,?>) current).getLeafChild(localName);
this.schema.push(next);
@SuppressWarnings("unchecked")
T arg = (T) next.getDomPathArgument();
@Override
public void endNode() throws IOException {
- NodeCodecContext left = schema.pop();
+ NodeCodecContext<?> left = schema.pop();
// NormalizedNode writer does not have entry into case, but into choice
// so for leaving case, we do not emit endNode.
if (!(left instanceof CaseNodeCodecContext)) {
}
private Map.Entry<NodeIdentifier, Object> serializeLeaf(final String localName, final Object value) {
- Preconditions.checkArgument(current() instanceof DataObjectCodecContext<?>);
+ Preconditions.checkArgument(current() instanceof DataObjectCodecContext);
- DataObjectCodecContext<?> currentCasted = (DataObjectCodecContext<?>) current();
- LeafNodeCodecContext leafContext = currentCasted.getLeafChild(localName);
+ DataObjectCodecContext<?,?> currentCasted = (DataObjectCodecContext<?,?>) current();
+ LeafNodeCodecContext<?> leafContext = currentCasted.getLeafChild(localName);
NodeIdentifier domArg = (NodeIdentifier) leafContext.getDomPathArgument();
Object domValue = leafContext.getValueCodec().serialize(value);
@Override
public void leafSetEntryNode(final Object value) throws IOException, IllegalArgumentException {
- LeafNodeCodecContext ctx = (LeafNodeCodecContext) current();
+ LeafNodeCodecContext<?> ctx = (LeafNodeCodecContext<?>) current();
getDelegate().leafSetEntryNode(ctx.getValueCodec().serialize(value));
}
@Override
public void startMapEntryNode(final Identifier<?> key, final int childSizeHint) throws IOException, IllegalArgumentException {
duplicateSchemaEnter();
- NodeIdentifierWithPredicates identifier = ((KeyedListNodeCodecContext) current()).serialize(key);
+ NodeIdentifierWithPredicates identifier = ((KeyedListNodeCodecContext<?>) current()).serialize(key);
getDelegate().startMapEntryNode(identifier, childSizeHint);
};