From: Robert Varga Date: Tue, 12 Sep 2017 09:34:22 +0000 (+0200) Subject: Cleanup AugmentToGenType X-Git-Tag: release/oxygen~90 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=4c485f2682fe9f346cb0d85a5fffe7b7d2ae1f88;p=mdsal.git Cleanup AugmentToGenType - do not use a temporary ArrayList - use isEmpty() instead of size check Change-Id: I1a1045f7d83c3775c8c29b1f63139e7a5e2d9317 Signed-off-by: Robert Varga --- diff --git a/binding2/mdsal-binding2-generator-impl/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/impl/AugmentToGenType.java b/binding2/mdsal-binding2-generator-impl/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/impl/AugmentToGenType.java index 339ad82c79..3947ffd42e 100644 --- a/binding2/mdsal-binding2-generator-impl/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/impl/AugmentToGenType.java +++ b/binding2/mdsal-binding2-generator-impl/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/impl/AugmentToGenType.java @@ -20,7 +20,6 @@ import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Map.Entry; -import java.util.Set; import java.util.stream.Collectors; import org.opendaylight.mdsal.binding.javav2.generator.context.ModuleContext; import org.opendaylight.mdsal.binding.javav2.generator.spi.TypeProvider; @@ -117,7 +116,7 @@ final class AugmentToGenType { */ static Map generate(final Module module, final SchemaContext schemaContext, final TypeProvider typeProvider, final Map genCtx, - Map> genTypeBuilders, final boolean verboseClassComments) { + final Map> genTypeBuilders, final boolean verboseClassComments) { Preconditions.checkArgument(module != null, "Module reference cannot be NULL."); Preconditions.checkArgument(module.getName() != null, "Module name cannot be NULL."); @@ -167,12 +166,10 @@ final class AugmentToGenType { Preconditions.checkArgument(module != null, "Module reference cannot be NULL."); Preconditions.checkState(module.getAugmentations() != null, "Augmentations Set cannot be NULL."); - final Set augmentations = module.getAugmentations(); - final List sortedAugmentations = new ArrayList<>(augmentations).stream() + final List sortedAugmentations = module.getAugmentations().stream() .filter(aug -> !module.equals(findAugmentTargetModule(schemaContext, aug))) .collect(Collectors.toList()); - Collections.sort(sortedAugmentations, AUGMENT_COMP); - + sortedAugmentations.sort(AUGMENT_COMP); return sortedAugmentations; } @@ -209,7 +206,7 @@ final class AugmentToGenType { private static Map augmentationToGenTypes(final String basePackageName, final Entry> schemaPathAugmentListEntry, final Module module, final SchemaContext schemaContext, final boolean verboseClassComments, - Map genCtx, Map> genTypeBuilders, + Map genCtx, final Map> genTypeBuilders, final TypeProvider typeProvider) { Preconditions.checkArgument(basePackageName != null, "Package Name cannot be NULL."); Preconditions.checkArgument(schemaPathAugmentListEntry != null, "Augmentation List Entry cannot be NULL."); @@ -218,7 +215,7 @@ final class AugmentToGenType { "Augmentation List Entry does not contain Target Path (Target Path is NULL)."); final List augmentationSchemaList = schemaPathAugmentListEntry.getValue(); - Preconditions.checkState(augmentationSchemaList.size() > 0, + Preconditions.checkState(!augmentationSchemaList.isEmpty(), "Augmentation List cannot be empty."); SchemaNode targetSchemaNode = SchemaContextUtil.findDataSchemaNode(schemaContext, targetPath); @@ -266,7 +263,7 @@ final class AugmentToGenType { static Map usesAugmentationToGenTypes(final SchemaContext schemaContext, final String augmentPackageName, final List schemaPathAugmentListEntry, final Module module, final UsesNode usesNode, final DataNodeContainer usesNodeParent, Map genCtx, - Map> genTypeBuilders, final boolean verboseClassComments, + final Map> genTypeBuilders, final boolean verboseClassComments, final TypeProvider typeProvider, final BindingNamespaceType namespaceType) { Preconditions.checkArgument(augmentPackageName != null, "Package Name cannot be NULL."); @@ -419,8 +416,8 @@ final class AugmentToGenType { final String basePackageName, final Type targetType, final ChoiceSchemaNode targetNode, final List schemaPathAugmentListEntry, final DataNodeContainer usesNodeParent, - Map genCtx, final boolean verboseClassComments, - Map> genTypeBuilders, final TypeProvider typeProvider, + final Map genCtx, final boolean verboseClassComments, + final Map> genTypeBuilders, final TypeProvider typeProvider, final BindingNamespaceType namespaceType) { Preconditions.checkArgument(basePackageName != null, "Base Package Name cannot be NULL."); Preconditions.checkArgument(targetType != null, "Referenced Choice Type cannot be NULL.");