package org.opendaylight.yangtools.binding.data.codec.impl;
import com.google.common.collect.Iterables;
-
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
-
import org.opendaylight.yangtools.concepts.Codec;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.Identifiable;
import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
final class ListNodeCodecContext extends DataObjectCodecContext<ListSchemaNode> {
-
private final Codec<NodeIdentifierWithPredicates, IdentifiableItem<?, ?>> codec;
private final Method keyGetter;
protected Object dataFromNormalizedNode(final NormalizedNode<?, ?> node) {
if (node instanceof MapNode) {
return fromMap((MapNode) node);
- } else if(node instanceof MapEntryNode) {
+ } else if (node instanceof MapEntryNode) {
return fromMapEntry((MapEntryNode) node);
} else if (node instanceof UnkeyedListNode) {
return fromUnkeyedList((UnkeyedListNode) node);
- } else if(node instanceof UnkeyedListEntryNode) {
+ } else if (node instanceof UnkeyedListEntryNode) {
return fromUnkeyedListEntry((UnkeyedListEntryNode) node);
+ } else {
+ throw new IllegalStateException("Unsupported data type " + node.getClass());
}
- throw new IllegalStateException("Unsupported data type " + node.getClass());
}
private List<DataObject> fromMap(final MapNode nodes) {
}
private DataObject fromMapEntry(final MapEntryNode node) {
- return LazyDataObject.create(this, node);
+ return createBindingProxy(node);
}
private DataObject fromUnkeyedListEntry(final UnkeyedListEntryNode node) {
- return LazyDataObject.create(this, node);
+ return createBindingProxy(node);
}
private List<DataObject> fromUnkeyedList(final UnkeyedListNode nodes) {
}
@Override
+ @SuppressWarnings("rawtypes")
Object getBindingChildValue(final Method method, final NormalizedNodeContainer dom) {
- if (method.equals(keyGetter) && dom instanceof MapEntryNode) {
+ if (dom instanceof MapEntryNode && method.equals(keyGetter)) {
NodeIdentifierWithPredicates identifier = ((MapEntryNode) dom).getIdentifier();
return codec.deserialize(identifier).getKey();
}