2 * Copyright (c) 2013 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.yangtools.yang.data.impl.schema.transform.base.serializer;
10 import java.util.HashSet;
13 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
14 import org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode;
15 import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode;
16 import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
17 import org.opendaylight.yangtools.yang.data.impl.schema.SchemaUtils;
18 import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
19 import org.opendaylight.yangtools.yang.model.api.AugmentationTarget;
20 import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode;
21 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
24 * Abstract(base) serializer for ChoiceNodes, serializes elements of type E.
26 * @param <E> type of serialized elements
28 public abstract class ChoiceNodeBaseSerializer<E>
30 BaseDispatcherSerializer<E, ChoiceNode, org.opendaylight.yangtools.yang.model.api.ChoiceNode> {
33 protected final DataSchemaNode getSchemaForChild(final org.opendaylight.yangtools.yang.model.api.ChoiceNode schema,
34 final DataContainerChild<? extends InstanceIdentifier.PathArgument, ?> childNode) {
35 return SchemaUtils.findSchemaForChild(schema, childNode.getNodeType());
39 protected final AugmentationSchema getAugmentedCase(final org.opendaylight.yangtools.yang.model.api.ChoiceNode schema,
40 final AugmentationNode augmentationNode) {
41 return SchemaUtils.findSchemaForAugment(schema, augmentationNode.getIdentifier().getPossibleChildNames());
45 protected final Set<DataSchemaNode> getRealSchemasForAugment(final org.opendaylight.yangtools.yang.model.api.ChoiceNode schema, final AugmentationSchema augmentationSchema) {
46 Set<DataSchemaNode> aggregatedSchemas = new HashSet<>(SchemaUtils.getRealSchemasForAugment(schema, augmentationSchema));
48 for (ChoiceCaseNode choiceCaseNode : schema.getCases()) {
49 aggregatedSchemas.addAll(SchemaUtils.getRealSchemasForAugment((AugmentationTarget) choiceCaseNode, augmentationSchema));
52 return aggregatedSchemas;