- legacyToNormalized = new DataNormalizer(arg0);
- }
-
- private org.opendaylight.yangtools.yang.data.api.InstanceIdentifier toNormalizedAugmented(
- final InstanceIdentifier<?> augPath) {
- org.opendaylight.yangtools.yang.data.api.InstanceIdentifier processed = toNormalizedImpl(augPath);
- // If used instance identifier codec added supports for deserialization
- // of last AugmentationIdentifier we will just reuse it
- if(isAugmentationIdentifier(processed)) {
- return processed;
- }
- // Here we employ small trick - DataNormalizer injecst augmentation identifier if child is
- // also part of the path (since using a child we can safely identify augmentation)
- // so, we scan augmentation for children add it to path
- // and use original algorithm, then shorten it to last augmentation
- for (@SuppressWarnings("rawtypes") Class augChild : getAugmentationChildren(augPath.getTargetType())) {
- @SuppressWarnings("unchecked")
- InstanceIdentifier<?> childPath = augPath.child(augChild);
- org.opendaylight.yangtools.yang.data.api.InstanceIdentifier normalized = toNormalizedImpl(childPath);
- org.opendaylight.yangtools.yang.data.api.InstanceIdentifier potentialDiscovered = shortenToLastAugmentation(normalized);
- if (potentialDiscovered != null) {
- return potentialDiscovered;
- }
- }
- return processed;
- }
-
-
-
- private org.opendaylight.yangtools.yang.data.api.InstanceIdentifier shortenToLastAugmentation(
- final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier normalized) {
- int position = 0;
- int foundPosition = -1;
- for (PathArgument arg : normalized.getPath()) {
- position++;
- if (arg instanceof AugmentationIdentifier) {
- foundPosition = position;
+ legacyToNormalized = new DataNormalizer (arg0);
+ runtimeContext = BindingRuntimeContext.create(classLoadingStrategy, arg0);
+ codecRegistry.onBindingRuntimeContextUpdated(runtimeContext);
+ }
+
+ public <T extends DataObject> Function<Optional<NormalizedNode<?, ?>>, Optional<T>> deserializeFunction(final InstanceIdentifier<T> path) {
+ return codecRegistry.deserializeFunction(path);
+ }
+
+ /**
+ * Returns an default object according to YANG schema for supplied path.
+ *
+ * @param path DOM Path
+ * @return Node with defaults set on.
+ */
+ public NormalizedNode<?, ?> getDefaultNodeFor(final YangInstanceIdentifier path) {
+ final Iterator<PathArgument> iterator = path.getPathArguments().iterator();
+ DataNormalizationOperation<?> currentOp = legacyToNormalized.getRootOperation();
+ while (iterator.hasNext()) {
+ final PathArgument currentArg = iterator.next();
+ try {
+ currentOp = currentOp.getChild(currentArg);
+ } catch (final DataNormalizationException e) {
+ throw new IllegalArgumentException(String.format("Invalid child encountered in path %s", path), e);