import static com.google.common.base.Preconditions.checkArgument;
-import com.google.common.base.Preconditions;
-import com.google.common.base.Predicates;
-import com.google.common.collect.FluentIterable;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Iterables;
-
import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.Iterator;
import org.opendaylight.yangtools.yang.data.impl.util.CompositeNodeBuilder;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import com.google.common.base.Preconditions;
+import com.google.common.base.Predicates;
+import com.google.common.collect.FluentIterable;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Iterables;
+
public class DataNormalizer {
private final DataNormalizationOperation<?> operation;
return InstanceIdentifier.create(normalizedArgs.build());
}
+ public DataNormalizationOperation<?> getOperation(final InstanceIdentifier legacy) throws DataNormalizationException {
+ DataNormalizationOperation<?> currentOp = operation;
+ Iterator<PathArgument> arguments = legacy.getPathArguments().iterator();
+
+ while (arguments.hasNext()) {
+ currentOp = currentOp.getChild(arguments.next());
+ }
+ return currentOp;
+ }
+
public Map.Entry<InstanceIdentifier, NormalizedNode<?, ?>> toNormalized(
final Map.Entry<InstanceIdentifier, CompositeNode> legacy) {
return toNormalized(legacy.getKey(), legacy.getValue());
DataNormalizationOperation<?> currentOp = operation;
for (PathArgument normalizedArg : normalized.getPathArguments()) {
currentOp = currentOp.getChild(normalizedArg);
- if(!currentOp.isMixin()) {
+ if (!currentOp.isMixin()) {
legacyArgs.add(normalizedArg);
}
}
return toLegacyFromDataContainer((DataContainerNode<?>) normalizedData);
} else if (normalizedData instanceof AnyXmlNode) {
Node<?> value = ((AnyXmlNode) normalizedData).getValue();
- return value instanceof CompositeNode ? (CompositeNode)value : null;
+ return value instanceof CompositeNode ? (CompositeNode) value : null;
}
return null;
}
for (NormalizedNode<?, ?> child : node.getValue()) {
if (child instanceof MixinNode && child instanceof NormalizedNodeContainer<?, ?, ?>) {
builder.addAll(toLegacyNodesFromMixin((NormalizedNodeContainer) child));
- } else if( child instanceof UnkeyedListNode) {
+ } else if (child instanceof UnkeyedListNode) {
builder.addAll(toLegacyNodesFromUnkeyedList((UnkeyedListNode) child));
} else {
addToBuilder(builder, toLegacy(child));