2 * Copyright (c) 2017 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.javav2.dom.codec.generator.spi.source;
10 import com.google.common.annotations.Beta;
11 import com.google.common.base.Preconditions;
12 import java.util.ArrayList;
13 import java.util.Collection;
14 import org.opendaylight.mdsal.binding.javav2.dom.codec.generator.spi.generator.AbstractGenerator;
15 import org.opendaylight.mdsal.binding.javav2.model.api.GeneratedType;
16 import org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode;
17 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
18 import org.slf4j.Logger;
19 import org.slf4j.LoggerFactory;
22 public abstract class AbstractAugmentSerializerSource extends AbstractDataNodeContainerSerializerSource {
24 private static final Logger LOG = LoggerFactory.getLogger(AbstractAugmentSerializerSource.class);
25 private final Collection<AugmentationSchemaNode> augmentationSchemas;
27 public AbstractAugmentSerializerSource(final AbstractGenerator generator, final GeneratedType type,
28 final Collection<AugmentationSchemaNode> augmentationSchemas) {
29 // Note: passing first augmentation schema node just to avoid exceptions from super class.
30 super(generator, type, augmentationSchemas.stream().findFirst().get());
31 this.augmentationSchemas = Preconditions.checkNotNull(augmentationSchemas);
35 * Override {@link AbstractDataNodeContainerSerializerSource#getChildNodes()} to get all children nodes
36 * of same target augmentation schema nodes.
39 protected Collection<DataSchemaNode> getChildNodes() {
40 Collection<DataSchemaNode> childNodes = new ArrayList<>();
41 for (AugmentationSchemaNode schema : this.augmentationSchemas) {
42 childNodes.addAll(schema.getChildNodes());