/*
* Copyright (c) 2017 Cisco Systems, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
package org.opendaylight.mdsal.binding.javav2.generator.yang.types;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.opendaylight.yangtools.util.TopologicalSort;
import org.opendaylight.yangtools.util.TopologicalSort.Node;
import org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode;
import org.opendaylight.yangtools.yang.model.api.CaseSchemaNode;
import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode;
import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
import org.opendaylight.yangtools.yang.model.api.GroupingDefinition;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
import org.opendaylight.yangtools.yang.model.api.UsesNode;
public class GroupingDefinitionDependencySort {
/**
* Sorts set groupingDefinitions
according to the mutual dependencies.
*
*
* Elements of
* The map with mapping from schema path (represents grouping definition) to
* node is created. For every created node (next nodeFrom) is for its
* wrapped grouping definition passed the set of its uses nodes
* through. For every uses node is found its wrapping node (next as
* nodeTo). This dependency relationship between nodeFrom and all
* found nodesTo is modeled with creating of one edge from nodeFrom to
* nodeTo.
*
*
* @param groupingDefinitions
* set of goruping definition which will be wrapped to nodes
*
* @return set of nodes where every one contains wrapped grouping definition
*/
private SetgroupingDefinitions
are firstly transformed to {@link Node} interfaces and then are
* sorted by {@link TopologicalSort#sort(Set)} method.
*
*
* Definition of dependency relation:
* The first GroupingDefinition
object (in this context)
* depends on second GroupingDefinition
object if the first one
* contains in its set of UsesNode
(obtained through
* {@link org.opendaylight.yangtools.yang.model.api.DataNodeContainer#getUses()
* getUses} method) reference to the second one.
*
* @param groupingDefinitions
* set of grouping definition which should be sorted according to
* mutual dependencies
* @return list of grouping definitiond which are sorted by mutual
* dependencies
* @throws IllegalArgumentException
* if groupingDefinitions
*
*/
public Listcontainer
, from uses in groupings inside
* container
and from uses inside child nodes of the
* container
.
*
* @param container
* data node container which can contain some uses of grouping
* @return set of uses nodes which were find in container
.
*/
private Set