+ return generatedTypes;
+ }
+
+ private List<Type> allContainersToGenTypes(final Module module) {
+ if (module == null) {
+ throw new IllegalArgumentException("Module reference cannot be NULL!");
+ }
+
+ if (module.getName() == null) {
+ throw new IllegalArgumentException("Module name cannot be NULL!");
+ }
+
+ if (module.getChildNodes() == null) {
+ throw new IllegalArgumentException("Reference to Set of Child " +
+ "Nodes in module " + module.getName() + " cannot be " +
+ "NULL!");
+ }
+
+ final List<Type> generatedTypes = new ArrayList<>();
+ final DataNodeIterator it = new DataNodeIterator(
+ module);
+ final List<ContainerSchemaNode> schemaContainers = it.allContainers();
+ final String basePackageName = moduleNamespaceToPackageName(module);
+ for (final ContainerSchemaNode container : schemaContainers) {
+ generatedTypes.add(containerToGenType(basePackageName,
+ container));
+ }
+ return generatedTypes;
+ }
+
+ private List<Type> allListsToGenTypes(final Module module) {
+ if (module == null) {
+ throw new IllegalArgumentException("Module reference cannot be NULL!");
+ }
+
+ if (module.getName() == null) {
+ throw new IllegalArgumentException("Module name cannot be NULL!");
+ }
+
+ if (module.getChildNodes() == null) {
+ throw new IllegalArgumentException("Reference to Set of Child " +
+ "Nodes in module " + module.getName() + " cannot be " +
+ "NULL!");
+ }
+
+ final List<Type> generatedTypes = new ArrayList<>();
+ final DataNodeIterator it = new DataNodeIterator(
+ module);
+ final List<ListSchemaNode> schemaLists = it.allLists();
+ final String basePackageName = moduleNamespaceToPackageName(module);
+ if (schemaLists != null) {
+ for (final ListSchemaNode list : schemaLists) {
+ generatedTypes.addAll(listToGenType(basePackageName, list));
+ }
+ }
+ return generatedTypes;
+ }
+
+ private List<Type> allAugmentsToGenTypes(final Module module) {
+ if (module == null) {
+ throw new IllegalArgumentException("Module reference cannot be NULL!");
+ }
+
+ if (module.getName() == null) {
+ throw new IllegalArgumentException("Module name cannot be NULL!");
+ }
+
+ if (module.getChildNodes() == null) {
+ throw new IllegalArgumentException("Reference to Set of " +
+ "Augmentation Definitions in module " + module.getName()
+ + " cannot be NULL!");
+ }
+
+ final List<Type> generatedTypes = new ArrayList<>();
+ final String basePackageName = moduleNamespaceToPackageName(module);
+ final List<AugmentationSchema> augmentations = resolveAugmentations(module);
+ for (final AugmentationSchema augment : augmentations) {
+ generatedTypes.addAll(augmentationToGenTypes(basePackageName, augment));
+ }
+ return generatedTypes;
+ }
+
+ private List<AugmentationSchema> resolveAugmentations(final Module module) {
+ if (module == null) {
+ throw new IllegalArgumentException("Module reference cannot be NULL!");
+ }
+ if (module.getAugmentations() == null) {
+ throw new IllegalStateException("Augmentations Set cannot be NULL!");
+ }
+
+ final Set<AugmentationSchema> augmentations = module
+ .getAugmentations();
+ final List<AugmentationSchema> sortedAugmentations = new ArrayList<>(
+ augmentations);
+ Collections.sort(sortedAugmentations,
+ new Comparator<AugmentationSchema>() {
+
+ @Override
+ public int compare(
+ AugmentationSchema augSchema1,
+ AugmentationSchema augSchema2) {
+
+ if (augSchema1.getTargetPath().getPath()
+ .size() > augSchema2
+ .getTargetPath().getPath().size()) {
+ return 1;
+ } else if (augSchema1.getTargetPath()
+ .getPath().size() < augSchema2
+ .getTargetPath().getPath().size()) {
+ return -1;
+ }
+ return 0;
+
+ }
+ });
+
+ return sortedAugmentations;