2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.mdsal.binding.dom.codec.impl;
10 import com.google.common.collect.ImmutableSet;
12 import org.opendaylight.mdsal.binding.dom.codec.api.BindingAugmentationCodecTreeNode;
13 import org.opendaylight.mdsal.binding.runtime.api.AugmentRuntimeType;
14 import org.opendaylight.yangtools.yang.binding.Augmentation;
15 import org.opendaylight.yangtools.yang.binding.DataObject;
16 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
17 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
18 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
19 import org.opendaylight.yangtools.yang.data.api.schema.DataContainerNode;
20 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
22 final class AugmentationCodecContext<D extends DataObject & Augmentation<?>>
23 extends AbstractDataObjectCodecContext<D, AugmentRuntimeType> implements BindingAugmentationCodecTreeNode<D> {
24 AugmentationCodecContext(final AugmentationCodecPrototype prototype) {
25 super(prototype, new CodecDataObjectAnalysis<>(prototype, CodecItemFactory.of(), null));
29 public PathArgument serializePathArgument(final InstanceIdentifier.PathArgument arg) {
30 if (!bindingArg().equals(arg)) {
31 throw new IllegalArgumentException("Unexpected argument " + arg);
37 public InstanceIdentifier.PathArgument deserializePathArgument(final PathArgument arg) {
39 throw new IllegalArgumentException("Unexpected argument " + arg);
45 public D filterFrom(final DataContainerNode parentData) {
46 for (var childArg : ((AugmentationCodecPrototype) prototype).getChildArgs()) {
47 if (parentData.childByArg(childArg) != null) {
48 return createBindingProxy(parentData);
55 public ImmutableSet<NodeIdentifier> childPathArguments() {
56 return byYangKeySet();
60 protected Object deserializeObject(final NormalizedNode normalizedNode) {
61 return filterFrom(checkDataArgument(DataContainerNode.class, normalizedNode));
65 protected NodeIdentifier getDomPathArgument() {
70 Map<Class<? extends Augmentation<?>>, Augmentation<?>> getAllAugmentationsFrom(final DataContainerNode data) {