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