From 4da5ba1945287ec0aab42d16048c75bac1583fd1 Mon Sep 17 00:00:00 2001 From: Jakub Toth Date: Tue, 21 Feb 2017 12:28:10 +0100 Subject: [PATCH] Bug 6859 #2 Binding generator v1 refactoring Based on transfer of Binding generator v1 from Yangtools project to MDSAL in past, we need to finalize this process by refactoring package naming: org.opendaylight.yangtools -> org.mdsal.binding org.opendaylight.yangtools.sal -> org.mdsal.binding This refactoring is done in subsequent steps, covering all necessary modules. Based on experience, this should also help users to address possible Binding generator v1 issues in MDSAL project, not in Yangtools. - mdsal-binding-generator-util module refactoring Change-Id: I978e49a68458d08a9d397a1a2d4bcc455eea1a37 Signed-off-by: Jakub Toth --- .../sal/api/gen/plugin/CodeGeneratorImpl.java | 2 +- .../impl/AbstractStreamWriterGenerator.java | 2 +- .../generator/impl/BindingGeneratorImpl.java | 42 +- .../generator/util/BindingRuntimeContext.java | 2 +- .../sal/binding/yang/types/BaseYangTypes.java | 2 +- .../binding/yang/types/TypeProviderImpl.java | 14 +- .../generator/impl/BaseTypeProvider.java | 2 +- .../binding/yang/types/BaseYangTypesTest.java | 2 +- .../yang/types/TypeProviderImplTest.java | 2 +- .../generator/util/AbstractBaseType.java | 25 +- .../generator/util/BindingGeneratorUtil.java | 38 +- .../binding/generator/util/BindingTypes.java | 5 +- .../generator/util/ReferencedTypeImpl.java | 5 +- .../mdsal/binding/generator/util/Types.java | 10 +- .../type/builder/AbstractGeneratedType.java | 39 +- .../builder/AbstractGeneratedTypeBuilder.java | 60 +- .../type/builder/AbstractTypeMember.java | 24 +- .../builder/AbstractTypeMemberBuilder.java | 24 +- .../builder/AnnotationTypeBuilderImpl.java | 88 +-- .../generated/type/builder/ConstantImpl.java | 38 +- .../type/builder/EnumerationBuilderImpl.java | 74 +- .../builder/GeneratedPropertyBuilderImpl.java | 15 +- .../type/builder/GeneratedPropertyImpl.java | 17 +- .../type/builder/GeneratedTOBuilderImpl.java | 68 +- .../builder/GeneratedTypeBuilderImpl.java | 20 +- .../type/builder/MethodParameterImpl.java | 20 +- .../builder/MethodSignatureBuilderImpl.java | 20 +- .../type/builder/MethodSignatureImpl.java | 18 +- .../generator/util/AbstractBaseType.java | 102 --- .../generator/util/BindingGeneratorUtil.java | 645 ------------------ .../binding/generator/util/BindingTypes.java | 60 -- .../generator/util/ReferencedTypeImpl.java | 42 -- .../binding/generator/util/TypeConstants.java | 30 - .../binding/generator/util/Types.java | 394 ----------- .../type/builder/AbstractGeneratedType.java | 218 ------ .../builder/AbstractGeneratedTypeBuilder.java | 245 ------- .../type/builder/AbstractTypeMember.java | 132 ---- .../builder/AbstractTypeMemberBuilder.java | 170 ----- .../builder/AnnotationTypeBuilderImpl.java | 309 --------- .../generated/type/builder/ConstantImpl.java | 118 ---- .../type/builder/EnumerationBuilderImpl.java | 385 ----------- .../builder/GeneratedPropertyBuilderImpl.java | 73 -- .../type/builder/GeneratedPropertyImpl.java | 69 -- .../type/builder/GeneratedTOBuilderImpl.java | 359 ---------- .../builder/GeneratedTypeBuilderImpl.java | 123 ---- .../type/builder/MethodParameterImpl.java | 90 --- .../builder/MethodSignatureBuilderImpl.java | 108 --- .../type/builder/MethodSignatureImpl.java | 104 --- .../binding/generator/util/package-info.java | 8 - .../sal/java/api/generator/BaseTemplate.xtend | 2 +- .../java/api/generator/BuilderTemplate.xtend | 8 +- .../java/api/generator/ClassTemplate.xtend | 2 +- .../sal/java/api/generator/EnumTemplate.xtend | 2 +- .../sal/java/api/generator/GeneratorUtil.java | 4 +- .../api/generator/InterfaceTemplate.xtend | 2 +- .../java/api/generator/UnionTemplate.xtend | 3 +- .../generator/YangModuleInfoTemplate.xtend | 2 +- .../java/api/generator/GeneratorUtilTest.java | 2 +- .../test/ClassCodeGeneratorTest.java | 4 +- .../generator/test/GeneratorJavaFileTest.java | 6 +- 60 files changed, 354 insertions(+), 4145 deletions(-) delete mode 100644 binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/AbstractBaseType.java delete mode 100644 binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/BindingGeneratorUtil.java delete mode 100644 binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/BindingTypes.java delete mode 100644 binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/ReferencedTypeImpl.java delete mode 100644 binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/TypeConstants.java delete mode 100644 binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/Types.java delete mode 100644 binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/AbstractGeneratedType.java delete mode 100644 binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/AbstractGeneratedTypeBuilder.java delete mode 100644 binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/AbstractTypeMember.java delete mode 100644 binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/AbstractTypeMemberBuilder.java delete mode 100644 binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/AnnotationTypeBuilderImpl.java delete mode 100644 binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/ConstantImpl.java delete mode 100644 binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/EnumerationBuilderImpl.java delete mode 100644 binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/GeneratedPropertyBuilderImpl.java delete mode 100644 binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/GeneratedPropertyImpl.java delete mode 100644 binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/GeneratedTOBuilderImpl.java delete mode 100644 binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/GeneratedTypeBuilderImpl.java delete mode 100644 binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/MethodParameterImpl.java delete mode 100644 binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/MethodSignatureBuilderImpl.java delete mode 100644 binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/MethodSignatureImpl.java delete mode 100644 binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/package-info.java diff --git a/binding/maven-sal-api-gen-plugin/src/main/java/org/opendaylight/yangtools/maven/sal/api/gen/plugin/CodeGeneratorImpl.java b/binding/maven-sal-api-gen-plugin/src/main/java/org/opendaylight/yangtools/maven/sal/api/gen/plugin/CodeGeneratorImpl.java index 20794bea2d..c57087715a 100644 --- a/binding/maven-sal-api-gen-plugin/src/main/java/org/opendaylight/yangtools/maven/sal/api/gen/plugin/CodeGeneratorImpl.java +++ b/binding/maven-sal-api-gen-plugin/src/main/java/org/opendaylight/yangtools/maven/sal/api/gen/plugin/CodeGeneratorImpl.java @@ -26,8 +26,8 @@ import java.util.Set; import java.util.function.Function; import org.apache.maven.project.MavenProject; import org.opendaylight.mdsal.binding.generator.api.BindingGenerator; +import org.opendaylight.mdsal.binding.generator.util.BindingGeneratorUtil; import org.opendaylight.mdsal.binding.model.api.Type; -import org.opendaylight.yangtools.binding.generator.util.BindingGeneratorUtil; import org.opendaylight.yangtools.sal.binding.generator.impl.BindingGeneratorImpl; import org.opendaylight.yangtools.sal.java.api.generator.GeneratorJavaFile; import org.opendaylight.yangtools.sal.java.api.generator.YangModuleInfoTemplate; diff --git a/binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/yangtools/binding/data/codec/gen/impl/AbstractStreamWriterGenerator.java b/binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/yangtools/binding/data/codec/gen/impl/AbstractStreamWriterGenerator.java index 2ec1d4848c..068a236f56 100644 --- a/binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/yangtools/binding/data/codec/gen/impl/AbstractStreamWriterGenerator.java +++ b/binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/yangtools/binding/data/codec/gen/impl/AbstractStreamWriterGenerator.java @@ -21,10 +21,10 @@ import javassist.CtField; import javassist.CtMethod; import javassist.Modifier; import javassist.NotFoundException; +import org.opendaylight.mdsal.binding.generator.util.Types; import org.opendaylight.mdsal.binding.model.api.GeneratedType; import org.opendaylight.yangtools.binding.data.codec.gen.spi.StaticConstantDefinition; import org.opendaylight.yangtools.binding.data.codec.util.AugmentableDispatchSerializer; -import org.opendaylight.yangtools.binding.generator.util.Types; import org.opendaylight.yangtools.sal.binding.generator.util.BindingRuntimeContext; import org.opendaylight.yangtools.sal.binding.generator.util.ClassCustomizer; import org.opendaylight.yangtools.sal.binding.generator.util.JavassistUtils; diff --git a/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/yangtools/sal/binding/generator/impl/BindingGeneratorImpl.java b/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/yangtools/sal/binding/generator/impl/BindingGeneratorImpl.java index f3c89a5499..cf4c1aa6c5 100644 --- a/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/yangtools/sal/binding/generator/impl/BindingGeneratorImpl.java +++ b/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/yangtools/sal/binding/generator/impl/BindingGeneratorImpl.java @@ -10,20 +10,20 @@ package org.opendaylight.yangtools.sal.binding.generator.impl; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkState; -import static org.opendaylight.yangtools.binding.generator.util.BindingGeneratorUtil.computeDefaultSUID; -import static org.opendaylight.yangtools.binding.generator.util.BindingGeneratorUtil.encodeAngleBrackets; -import static org.opendaylight.yangtools.binding.generator.util.BindingGeneratorUtil.packageNameForAugmentedGeneratedType; -import static org.opendaylight.yangtools.binding.generator.util.BindingGeneratorUtil.packageNameForGeneratedType; -import static org.opendaylight.yangtools.binding.generator.util.BindingTypes.DATA_OBJECT; -import static org.opendaylight.yangtools.binding.generator.util.BindingTypes.DATA_ROOT; -import static org.opendaylight.yangtools.binding.generator.util.BindingTypes.IDENTIFIABLE; -import static org.opendaylight.yangtools.binding.generator.util.BindingTypes.IDENTIFIER; -import static org.opendaylight.yangtools.binding.generator.util.BindingTypes.NOTIFICATION; -import static org.opendaylight.yangtools.binding.generator.util.BindingTypes.augmentable; -import static org.opendaylight.yangtools.binding.generator.util.Types.BOOLEAN; -import static org.opendaylight.yangtools.binding.generator.util.Types.FUTURE; -import static org.opendaylight.yangtools.binding.generator.util.Types.VOID; -import static org.opendaylight.yangtools.binding.generator.util.Types.typeForClass; +import static org.opendaylight.mdsal.binding.generator.util.BindingGeneratorUtil.computeDefaultSUID; +import static org.opendaylight.mdsal.binding.generator.util.BindingGeneratorUtil.encodeAngleBrackets; +import static org.opendaylight.mdsal.binding.generator.util.BindingGeneratorUtil.packageNameForAugmentedGeneratedType; +import static org.opendaylight.mdsal.binding.generator.util.BindingGeneratorUtil.packageNameForGeneratedType; +import static org.opendaylight.mdsal.binding.generator.util.BindingTypes.DATA_OBJECT; +import static org.opendaylight.mdsal.binding.generator.util.BindingTypes.DATA_ROOT; +import static org.opendaylight.mdsal.binding.generator.util.BindingTypes.IDENTIFIABLE; +import static org.opendaylight.mdsal.binding.generator.util.BindingTypes.IDENTIFIER; +import static org.opendaylight.mdsal.binding.generator.util.BindingTypes.NOTIFICATION; +import static org.opendaylight.mdsal.binding.generator.util.BindingTypes.augmentable; +import static org.opendaylight.mdsal.binding.generator.util.Types.BOOLEAN; +import static org.opendaylight.mdsal.binding.generator.util.Types.FUTURE; +import static org.opendaylight.mdsal.binding.generator.util.Types.VOID; +import static org.opendaylight.mdsal.binding.generator.util.Types.typeForClass; import static org.opendaylight.yangtools.yang.model.util.SchemaContextUtil.findDataSchemaNode; import static org.opendaylight.yangtools.yang.model.util.SchemaContextUtil.findNodeInSchemaContext; import static org.opendaylight.yangtools.yang.model.util.SchemaContextUtil.findParentModule; @@ -46,6 +46,13 @@ import java.util.Set; import java.util.regex.Pattern; import org.opendaylight.mdsal.binding.generator.api.BindingGenerator; import org.opendaylight.mdsal.binding.generator.spi.TypeProvider; +import org.opendaylight.mdsal.binding.generator.util.BindingGeneratorUtil; +import org.opendaylight.mdsal.binding.generator.util.BindingTypes; +import org.opendaylight.mdsal.binding.generator.util.ReferencedTypeImpl; +import org.opendaylight.mdsal.binding.generator.util.Types; +import org.opendaylight.mdsal.binding.generator.util.generated.type.builder.GeneratedPropertyBuilderImpl; +import org.opendaylight.mdsal.binding.generator.util.generated.type.builder.GeneratedTOBuilderImpl; +import org.opendaylight.mdsal.binding.generator.util.generated.type.builder.GeneratedTypeBuilderImpl; import org.opendaylight.mdsal.binding.model.api.AccessModifier; import org.opendaylight.mdsal.binding.model.api.Constant; import org.opendaylight.mdsal.binding.model.api.GeneratedTransferObject; @@ -60,13 +67,6 @@ import org.opendaylight.mdsal.binding.model.api.type.builder.GeneratedTOBuilder; import org.opendaylight.mdsal.binding.model.api.type.builder.GeneratedTypeBuilder; import org.opendaylight.mdsal.binding.model.api.type.builder.GeneratedTypeBuilderBase; import org.opendaylight.mdsal.binding.model.api.type.builder.MethodSignatureBuilder; -import org.opendaylight.yangtools.binding.generator.util.BindingGeneratorUtil; -import org.opendaylight.yangtools.binding.generator.util.BindingTypes; -import org.opendaylight.yangtools.binding.generator.util.ReferencedTypeImpl; -import org.opendaylight.yangtools.binding.generator.util.Types; -import org.opendaylight.yangtools.binding.generator.util.generated.type.builder.GeneratedPropertyBuilderImpl; -import org.opendaylight.yangtools.binding.generator.util.generated.type.builder.GeneratedTOBuilderImpl; -import org.opendaylight.yangtools.binding.generator.util.generated.type.builder.GeneratedTypeBuilderImpl; import org.opendaylight.yangtools.sal.binding.yang.types.GroupingDefinitionDependencySort; import org.opendaylight.yangtools.sal.binding.yang.types.TypeProviderImpl; import org.opendaylight.yangtools.yang.binding.BaseIdentity; diff --git a/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/yangtools/sal/binding/generator/util/BindingRuntimeContext.java b/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/yangtools/sal/binding/generator/util/BindingRuntimeContext.java index 614208f91f..cfa09cf41a 100644 --- a/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/yangtools/sal/binding/generator/util/BindingRuntimeContext.java +++ b/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/yangtools/sal/binding/generator/util/BindingRuntimeContext.java @@ -27,12 +27,12 @@ import java.util.Map.Entry; import java.util.Set; import javax.annotation.Nullable; import org.opendaylight.mdsal.binding.generator.api.ClassLoadingStrategy; +import org.opendaylight.mdsal.binding.generator.util.ReferencedTypeImpl; import org.opendaylight.mdsal.binding.model.api.GeneratedType; import org.opendaylight.mdsal.binding.model.api.MethodSignature; import org.opendaylight.mdsal.binding.model.api.ParameterizedType; import org.opendaylight.mdsal.binding.model.api.Type; import org.opendaylight.mdsal.binding.model.api.type.builder.GeneratedTypeBuilder; -import org.opendaylight.yangtools.binding.generator.util.ReferencedTypeImpl; import org.opendaylight.yangtools.concepts.Immutable; import org.opendaylight.yangtools.sal.binding.generator.impl.BindingGeneratorImpl; import org.opendaylight.yangtools.sal.binding.generator.impl.BindingSchemaContextUtils; diff --git a/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/yangtools/sal/binding/yang/types/BaseYangTypes.java b/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/yangtools/sal/binding/yang/types/BaseYangTypes.java index 21f827734f..56cb6269c5 100644 --- a/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/yangtools/sal/binding/yang/types/BaseYangTypes.java +++ b/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/yangtools/sal/binding/yang/types/BaseYangTypes.java @@ -13,9 +13,9 @@ import java.math.BigDecimal; import java.math.BigInteger; import java.util.Map; import org.opendaylight.mdsal.binding.generator.spi.TypeProvider; +import org.opendaylight.mdsal.binding.generator.util.Types; import org.opendaylight.mdsal.binding.model.api.Restrictions; import org.opendaylight.mdsal.binding.model.api.Type; -import org.opendaylight.yangtools.binding.generator.util.Types; import org.opendaylight.yangtools.yang.binding.BindingMapping; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode; diff --git a/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/yangtools/sal/binding/yang/types/TypeProviderImpl.java b/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/yangtools/sal/binding/yang/types/TypeProviderImpl.java index 9068082886..7637ddc5af 100644 --- a/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/yangtools/sal/binding/yang/types/TypeProviderImpl.java +++ b/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/yangtools/sal/binding/yang/types/TypeProviderImpl.java @@ -7,7 +7,7 @@ */ package org.opendaylight.yangtools.sal.binding.yang.types; -import static org.opendaylight.yangtools.binding.generator.util.BindingGeneratorUtil.encodeAngleBrackets; +import static org.opendaylight.mdsal.binding.generator.util.BindingGeneratorUtil.encodeAngleBrackets; import static org.opendaylight.yangtools.yang.model.util.SchemaContextUtil.findDataSchemaNode; import static org.opendaylight.yangtools.yang.model.util.SchemaContextUtil.findDataSchemaNodeForRelativeXPath; import static org.opendaylight.yangtools.yang.model.util.SchemaContextUtil.findParentModule; @@ -35,6 +35,12 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import org.apache.commons.lang3.StringEscapeUtils; import org.opendaylight.mdsal.binding.generator.spi.TypeProvider; +import org.opendaylight.mdsal.binding.generator.util.BindingGeneratorUtil; +import org.opendaylight.mdsal.binding.generator.util.TypeConstants; +import org.opendaylight.mdsal.binding.generator.util.Types; +import org.opendaylight.mdsal.binding.generator.util.generated.type.builder.EnumerationBuilderImpl; +import org.opendaylight.mdsal.binding.generator.util.generated.type.builder.GeneratedPropertyBuilderImpl; +import org.opendaylight.mdsal.binding.generator.util.generated.type.builder.GeneratedTOBuilderImpl; import org.opendaylight.mdsal.binding.model.api.AccessModifier; import org.opendaylight.mdsal.binding.model.api.ConcreteType; import org.opendaylight.mdsal.binding.model.api.Enumeration; @@ -47,12 +53,6 @@ import org.opendaylight.mdsal.binding.model.api.type.builder.GeneratedPropertyBu import org.opendaylight.mdsal.binding.model.api.type.builder.GeneratedTOBuilder; import org.opendaylight.mdsal.binding.model.api.type.builder.GeneratedTypeBuilderBase; import org.opendaylight.mdsal.binding.model.api.type.builder.MethodSignatureBuilder; -import org.opendaylight.yangtools.binding.generator.util.BindingGeneratorUtil; -import org.opendaylight.yangtools.binding.generator.util.TypeConstants; -import org.opendaylight.yangtools.binding.generator.util.Types; -import org.opendaylight.yangtools.binding.generator.util.generated.type.builder.EnumerationBuilderImpl; -import org.opendaylight.yangtools.binding.generator.util.generated.type.builder.GeneratedPropertyBuilderImpl; -import org.opendaylight.yangtools.binding.generator.util.generated.type.builder.GeneratedTOBuilderImpl; import org.opendaylight.yangtools.yang.binding.BindingMapping; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.model.api.DataNodeContainer; diff --git a/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/yangtools/sal/binding/generator/impl/BaseTypeProvider.java b/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/yangtools/sal/binding/generator/impl/BaseTypeProvider.java index 95fad66ec4..26a17b6ee0 100644 --- a/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/yangtools/sal/binding/generator/impl/BaseTypeProvider.java +++ b/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/yangtools/sal/binding/generator/impl/BaseTypeProvider.java @@ -12,10 +12,10 @@ import static org.junit.Assert.assertTrue; import org.junit.Test; import org.opendaylight.mdsal.binding.generator.spi.TypeProvider; +import org.opendaylight.mdsal.binding.generator.util.Types; import org.opendaylight.mdsal.binding.model.api.ConcreteType; import org.opendaylight.mdsal.binding.model.api.ParameterizedType; import org.opendaylight.mdsal.binding.model.api.Type; -import org.opendaylight.yangtools.binding.generator.util.Types; import org.opendaylight.yangtools.sal.binding.yang.types.BaseYangTypes; public class BaseTypeProvider { diff --git a/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/yangtools/sal/binding/yang/types/BaseYangTypesTest.java b/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/yangtools/sal/binding/yang/types/BaseYangTypesTest.java index 1ff4f3a8e2..2e832b1994 100644 --- a/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/yangtools/sal/binding/yang/types/BaseYangTypesTest.java +++ b/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/yangtools/sal/binding/yang/types/BaseYangTypesTest.java @@ -20,8 +20,8 @@ import java.util.Set; import org.junit.BeforeClass; import org.junit.Test; import org.opendaylight.mdsal.binding.generator.spi.TypeProvider; +import org.opendaylight.mdsal.binding.generator.util.BindingGeneratorUtil; import org.opendaylight.mdsal.binding.model.api.Type; -import org.opendaylight.yangtools.binding.generator.util.BindingGeneratorUtil; import org.opendaylight.yangtools.yang.model.api.SchemaContext; import org.opendaylight.yangtools.yang.model.api.TypeDefinition; import org.opendaylight.yangtools.yang.model.api.type.BinaryTypeDefinition; diff --git a/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/yangtools/sal/binding/yang/types/TypeProviderImplTest.java b/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/yangtools/sal/binding/yang/types/TypeProviderImplTest.java index afe413126d..d0bd4ede9d 100644 --- a/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/yangtools/sal/binding/yang/types/TypeProviderImplTest.java +++ b/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/yangtools/sal/binding/yang/types/TypeProviderImplTest.java @@ -20,8 +20,8 @@ import java.io.File; import java.net.URI; import java.util.NoSuchElementException; import org.junit.Test; +import org.opendaylight.mdsal.binding.generator.util.generated.type.builder.GeneratedTypeBuilderImpl; import org.opendaylight.mdsal.binding.model.api.Type; -import org.opendaylight.yangtools.binding.generator.util.generated.type.builder.GeneratedTypeBuilderImpl; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; import org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode; diff --git a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/AbstractBaseType.java b/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/AbstractBaseType.java index c93e8dac19..127f018b4f 100644 --- a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/AbstractBaseType.java +++ b/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/AbstractBaseType.java @@ -12,7 +12,6 @@ import org.opendaylight.mdsal.binding.model.api.Type; /** * It is used only as ancestor for other Types - * */ public class AbstractBaseType implements Type { @@ -28,20 +27,20 @@ public class AbstractBaseType implements Type { @Override public String getPackageName() { - return packageName; + return this.packageName; } @Override public String getName() { - return name; + return this.name; } @Override public String getFullyQualifiedName() { - if (packageName.isEmpty()) { - return name; + if (this.packageName.isEmpty()) { + return this.name; } else { - return packageName + "." + name; + return this.packageName + "." + this.name; } } @@ -70,8 +69,8 @@ public class AbstractBaseType implements Type { public int hashCode() { final int prime = 31; int result = 1; - result = prime * result + Objects.hashCode(name); - result = prime * result + Objects.hashCode(packageName); + result = (prime * result) + Objects.hashCode(this.name); + result = (prime * result) + Objects.hashCode(this.packageName); return result; } @@ -86,15 +85,15 @@ public class AbstractBaseType implements Type { if (!(obj instanceof Type)) { return false; } - Type other = (Type) obj; - return Objects.equals(name, other.getName()) && Objects.equals(packageName, other.getPackageName()); + final Type other = (Type) obj; + return Objects.equals(this.name, other.getName()) && Objects.equals(this.packageName, other.getPackageName()); } @Override public String toString() { - if (packageName.isEmpty()) { - return "Type (" + name + ")"; + if (this.packageName.isEmpty()) { + return "Type (" + this.name + ")"; } - return "Type (" + packageName + "." + name + ")"; + return "Type (" + this.packageName + "." + this.name + ")"; } } diff --git a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/BindingGeneratorUtil.java b/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/BindingGeneratorUtil.java index f79ae30cc4..64faac82e2 100644 --- a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/BindingGeneratorUtil.java +++ b/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/BindingGeneratorUtil.java @@ -49,8 +49,6 @@ import org.opendaylight.yangtools.yang.model.util.type.DecimalTypeBuilder; /** * Contains the methods for converting strings to valid JAVA language strings * (package names, class names, attribute names) and to valid javadoc comments. - * - * */ public final class BindingGeneratorUtil { @@ -108,7 +106,7 @@ public final class BindingGeneratorUtil { * @return string with the admissible parameter name */ public static String resolveJavaReservedWordEquivalency(final String parameterName) { - if (parameterName != null && BindingMapping.JAVA_RESERVED_WORDS.contains(parameterName)) { + if ((parameterName != null) && BindingMapping.JAVA_RESERVED_WORDS.contains(parameterName)) { return "_" + parameterName; } return parameterName; @@ -196,7 +194,7 @@ public final class BindingGeneratorUtil { final Iterator iterator = path.iterator(); for (int i = 0; i < size; ++i) { builder.append('.'); - String nodeLocalName = iterator.next().getLocalName(); + final String nodeLocalName = iterator.next().getLocalName(); // FIXME: Collon ":" is invalid in node local name as per RFC6020, identifier statement. builder.append(DASH_COLON_MATCHER.replaceFrom(nodeLocalName, '.')); } @@ -348,7 +346,7 @@ public final class BindingGeneratorUtil { char firstChar = correctStr.charAt(0); firstChar = uppercase ? Character.toUpperCase(firstChar) : Character.toLowerCase(firstChar); - if (firstChar >= '0' && firstChar <= '9') { + if ((firstChar >= '0') && (firstChar <= '9')) { return '_' + correctStr; } else { return firstChar + correctStr.substring(1); @@ -375,8 +373,8 @@ public final class BindingGeneratorUtil { return text; } - StringBuilder sb = new StringBuilder(text); - String toBeRemoved = String.valueOf(removalChar); + final StringBuilder sb = new StringBuilder(text); + final String toBeRemoved = String.valueOf(removalChar); do { sb.replace(toBeRemovedPos, toBeRemovedPos + 1, ""); // check if 'toBeRemoved' character is not the only character in @@ -384,7 +382,7 @@ public final class BindingGeneratorUtil { if (sb.length() == 0) { throw new IllegalArgumentException("The resulting string can not be empty"); } - char replacement = Character.toUpperCase(sb.charAt(toBeRemovedPos)); + final char replacement = Character.toUpperCase(sb.charAt(toBeRemovedPos)); sb.setCharAt(toBeRemovedPos, replacement); toBeRemovedPos = sb.indexOf(toBeRemoved); } while (toBeRemovedPos != -1); @@ -407,7 +405,7 @@ public final class BindingGeneratorUtil { protected MessageDigest initialValue() { try { return MessageDigest.getInstance("SHA"); - } catch (NoSuchAlgorithmException e) { + } catch (final NoSuchAlgorithmException e) { throw new IllegalStateException("Failed to get a SHA digest provider", e); } } @@ -419,15 +417,15 @@ public final class BindingGeneratorUtil { dout.writeUTF(to.getName()); dout.writeInt(to.isAbstract() ? 3 : 7); - for (Type ifc : sortedCollection(SUID_NAME_COMPARATOR, to.getImplementsTypes())) { + for (final Type ifc : sortedCollection(SUID_NAME_COMPARATOR, to.getImplementsTypes())) { dout.writeUTF(ifc.getFullyQualifiedName()); } - for (GeneratedPropertyBuilder gp : sortedCollection(SUID_MEMBER_COMPARATOR, to.getProperties())) { + for (final GeneratedPropertyBuilder gp : sortedCollection(SUID_MEMBER_COMPARATOR, to.getProperties())) { dout.writeUTF(gp.getName()); } - for (MethodSignatureBuilder m : sortedCollection(SUID_MEMBER_COMPARATOR, to.getMethodDefinitions())) { + for (final MethodSignatureBuilder m : sortedCollection(SUID_MEMBER_COMPARATOR, to.getMethodDefinitions())) { if (!(m.getAccessModifier().equals(AccessModifier.PRIVATE))) { dout.writeUTF(m.getName()); dout.write(m.getAccessModifier().ordinal()); @@ -435,7 +433,7 @@ public final class BindingGeneratorUtil { } dout.flush(); - } catch (IOException e) { + } catch (final IOException e) { throw new IllegalStateException("Failed to hash object " + to, e); } @@ -469,7 +467,7 @@ public final class BindingGeneratorUtil { final Builder builder = ImmutableList.builder(); boolean filtered = false; - for (PatternConstraint c : constraints) { + for (final PatternConstraint c : constraints) { if (containsConstraint(type.getBaseType(), c)) { filtered = true; } else { @@ -483,7 +481,7 @@ public final class BindingGeneratorUtil { public static Restrictions getRestrictions(final TypeDefinition type) { // Old parser generated types which actually contained based restrictions, but our code deals with that when // binding to core Java types. Hence we'll emit empty restrictions for base types. - if (type == null || type.getBaseType() == null) { + if ((type == null) || (type.getBaseType() == null)) { // Handling of decimal64 has changed in the new parser. It contains range restrictions applied to the type // directly, without an extended type. We need to capture such constraints. In order to retain behavior we // need to analyze the new semantics and see if the constraints have been overridden. To do that we @@ -545,7 +543,7 @@ public final class BindingGeneratorUtil { if (type instanceof BinaryTypeDefinition) { final BinaryTypeDefinition binary = (BinaryTypeDefinition)type; final BinaryTypeDefinition base = binary.getBaseType(); - if (base != null && base.getBaseType() != null) { + if ((base != null) && (base.getBaseType() != null)) { length = currentOrEmpty(binary.getLengthConstraints(), base.getLengthConstraints()); } else { length = binary.getLengthConstraints(); @@ -559,7 +557,7 @@ public final class BindingGeneratorUtil { final DecimalTypeDefinition decimal = (DecimalTypeDefinition)type; final DecimalTypeDefinition base = decimal.getBaseType(); - if (base != null && base.getBaseType() != null) { + if ((base != null) && (base.getBaseType() != null)) { range = currentOrEmpty(decimal.getRangeConstraints(), base.getRangeConstraints()); } else { range = decimal.getRangeConstraints(); @@ -570,7 +568,7 @@ public final class BindingGeneratorUtil { final IntegerTypeDefinition integer = (IntegerTypeDefinition)type; final IntegerTypeDefinition base = integer.getBaseType(); - if (base != null && base.getBaseType() != null) { + if ((base != null) && (base.getBaseType() != null)) { range = currentOrEmpty(integer.getRangeConstraints(), base.getRangeConstraints()); } else { range = integer.getRangeConstraints(); @@ -578,7 +576,7 @@ public final class BindingGeneratorUtil { } else if (type instanceof StringTypeDefinition) { final StringTypeDefinition string = (StringTypeDefinition)type; final StringTypeDefinition base = string.getBaseType(); - if (base != null && base.getBaseType() != null) { + if ((base != null) && (base.getBaseType() != null)) { length = currentOrEmpty(string.getLengthConstraints(), base.getLengthConstraints()); } else { length = string.getLengthConstraints(); @@ -592,7 +590,7 @@ public final class BindingGeneratorUtil { final UnsignedIntegerTypeDefinition unsigned = (UnsignedIntegerTypeDefinition)type; final UnsignedIntegerTypeDefinition base = unsigned.getBaseType(); - if (base != null && base.getBaseType() != null) { + if ((base != null) && (base.getBaseType() != null)) { range = currentOrEmpty(unsigned.getRangeConstraints(), base.getRangeConstraints()); } else { range = unsigned.getRangeConstraints(); diff --git a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/BindingTypes.java b/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/BindingTypes.java index 4769234d8b..f5f4b4bb04 100644 --- a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/BindingTypes.java +++ b/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/BindingTypes.java @@ -9,7 +9,6 @@ package org.opendaylight.mdsal.binding.generator.util; import static org.opendaylight.mdsal.binding.generator.util.Types.parameterizedTypeFor; import static org.opendaylight.mdsal.binding.generator.util.Types.typeForClass; - import org.opendaylight.mdsal.binding.model.api.ConcreteType; import org.opendaylight.mdsal.binding.model.api.ParameterizedType; import org.opendaylight.mdsal.binding.model.api.Type; @@ -46,11 +45,11 @@ public final class BindingTypes { } - public static ParameterizedType augmentable(Type t) { + public static ParameterizedType augmentable(final Type t) { return parameterizedTypeFor(AUGMENTABLE, t); } - public static ParameterizedType childOf(Type t) { + public static ParameterizedType childOf(final Type t) { return parameterizedTypeFor(CHILD_OF, t); } diff --git a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/ReferencedTypeImpl.java b/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/ReferencedTypeImpl.java index 5c3585bb99..7ff4d7471f 100644 --- a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/ReferencedTypeImpl.java +++ b/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/ReferencedTypeImpl.java @@ -11,7 +11,6 @@ package org.opendaylight.mdsal.binding.generator.util; * * Wraps combination of packageName and name to the * object representation - * */ public final class ReferencedTypeImpl extends AbstractBaseType { @@ -23,13 +22,13 @@ public final class ReferencedTypeImpl extends AbstractBaseType { * @param name * string with the name for referenced type */ - public ReferencedTypeImpl(String packageName, String name) { + public ReferencedTypeImpl(final String packageName, final String name) { super(packageName, name); } @Override public String toString() { - StringBuilder builder = new StringBuilder(); + final StringBuilder builder = new StringBuilder(); builder.append("ReferencedTypeImpl [packageName="); builder.append(getPackageName()); builder.append(", name="); diff --git a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/Types.java b/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/Types.java index 1964d32a8e..bd06eddfa0 100644 --- a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/Types.java +++ b/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/Types.java @@ -256,7 +256,7 @@ public final class Types { @Override public Restrictions getRestrictions() { - return restrictions; + return this.restrictions; } } @@ -284,7 +284,7 @@ public final class Types { @Override public Restrictions getRestrictions() { - return restrictions; + return this.restrictions; } } @@ -307,12 +307,12 @@ public final class Types { @Override public Type[] getActualTypeArguments() { - return actualTypes; + return this.actualTypes; } @Override public Type getRawType() { - return rawType; + return this.rawType; } /** @@ -374,7 +374,7 @@ public final class Types { @Override public List getRangeConstraints() { - return rangeConstraints; + return this.rangeConstraints; } @Override diff --git a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/AbstractGeneratedType.java b/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/AbstractGeneratedType.java index b2df0a3c89..4c2b3c1fe1 100644 --- a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/AbstractGeneratedType.java +++ b/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/AbstractGeneratedType.java @@ -10,7 +10,6 @@ package org.opendaylight.mdsal.binding.generator.util.generated.type.builder; import java.util.ArrayList; import java.util.Collections; import java.util.List; - import org.opendaylight.mdsal.binding.generator.util.AbstractBaseType; import org.opendaylight.mdsal.binding.model.api.AnnotationType; import org.opendaylight.mdsal.binding.model.api.Constant; @@ -136,79 +135,79 @@ abstract class AbstractGeneratedType extends AbstractBaseType implements Generat @Override public final Type getParentType() { - return parent; + return this.parent; } @Override public final String getComment() { - return comment; + return this.comment; } @Override public final List getAnnotations() { - return annotations; + return this.annotations; } @Override public final boolean isAbstract() { - return isAbstract; + return this.isAbstract; } @Override public final List getImplements() { - return implementsTypes; + return this.implementsTypes; } @Override public final List getEnclosedTypes() { - return enclosedTypes; + return this.enclosedTypes; } @Override public final List getEnumerations() { - return enumerations; + return this.enumerations; } @Override public final List getConstantDefinitions() { - return constants; + return this.constants; } @Override public final List getMethodDefinitions() { - return methodSignatures; + return this.methodSignatures; } @Override public final List getProperties() { - return properties; + return this.properties; } @Override public String toString() { - StringBuilder builder = new StringBuilder(); + final StringBuilder builder = new StringBuilder(); builder.append("GeneratedType [packageName="); builder.append(getPackageName()); builder.append(", name="); builder.append(getName()); - if (parent != null) { + if (this.parent != null) { builder.append(", parent="); - builder.append(parent.getFullyQualifiedName()); + builder.append(this.parent.getFullyQualifiedName()); } else { builder.append(", parent=null"); } builder.append(", comment="); - builder.append(comment); + builder.append(this.comment); builder.append(", annotations="); - builder.append(annotations); + builder.append(this.annotations); builder.append(", enclosedTypes="); - builder.append(enclosedTypes); + builder.append(this.enclosedTypes); builder.append(", enumerations="); - builder.append(enumerations); + builder.append(this.enumerations); builder.append(", constants="); - builder.append(constants); + builder.append(this.constants); builder.append(", methodSignatures="); - builder.append(methodSignatures); + builder.append(this.methodSignatures); builder.append("]"); return builder.toString(); } diff --git a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/AbstractGeneratedTypeBuilder.java b/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/AbstractGeneratedTypeBuilder.java index 223faebd93..c1430102e1 100644 --- a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/AbstractGeneratedTypeBuilder.java +++ b/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/AbstractGeneratedTypeBuilder.java @@ -42,42 +42,42 @@ abstract class AbstractGeneratedTypeBuilder getAnnotations() { - return annotationBuilders; + return this.annotationBuilders; } @Override public boolean isAbstract() { - return isAbstract; + return this.isAbstract; } @Override public List getImplementsTypes() { - return implementsTypes; + return this.implementsTypes; } protected List getEnumerations() { - return enumDefinitions; + return this.enumDefinitions; } protected List getConstants() { - return constants; + return this.constants; } @Override public List getMethodDefinitions() { - return methodDefinitions; + return this.methodDefinitions; } protected List getEnclosedTypes() { - return enclosedTypes; + return this.enclosedTypes; } protected List getEnclosedTransferObjects() { - return enclosedTransferObjects; + return this.enclosedTransferObjects; } protected abstract T thisInstance(); @@ -85,18 +85,18 @@ abstract class AbstractGeneratedTypeBuilder other = (AbstractGeneratedTypeBuilder) obj; + final AbstractGeneratedTypeBuilder other = (AbstractGeneratedTypeBuilder) obj; return Objects.equals(getName(), other.getName()) && Objects.equals(getPackageName(), other.getPackageName()); } @@ -236,6 +236,6 @@ abstract class AbstractGeneratedTypeBuilder getProperties() { - return properties; + return this.properties; } } diff --git a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/AbstractTypeMember.java b/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/AbstractTypeMember.java index 88347e6490..6bdd0aaaab 100644 --- a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/AbstractTypeMember.java +++ b/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/AbstractTypeMember.java @@ -41,50 +41,50 @@ abstract class AbstractTypeMember implements TypeMember { @Override public List getAnnotations() { - return annotations; + return this.annotations; } @Override public String getName() { - return name; + return this.name; } @Override public String getComment() { - return comment; + return this.comment; } @Override public Type getDefiningType() { - return definingType; + return this.definingType; } @Override public AccessModifier getAccessModifier() { - return accessModifier; + return this.accessModifier; } @Override public Type getReturnType() { - return returnType; + return this.returnType; } @Override public boolean isFinal() { - return isFinal; + return this.isFinal; } @Override public boolean isStatic() { - return isStatic; + return this.isStatic; } @Override public int hashCode() { final int prime = 31; int result = 1; - result = prime * result + Objects.hashCode(getName()); - result = prime * result + Objects.hashCode(getReturnType()); + result = (prime * result) + Objects.hashCode(getName()); + result = (prime * result) + Objects.hashCode(getReturnType()); return result; } @@ -99,13 +99,13 @@ abstract class AbstractTypeMember implements TypeMember { if (getClass() != obj.getClass()) { return false; } - AbstractTypeMember other = (AbstractTypeMember) obj; + final AbstractTypeMember other = (AbstractTypeMember) obj; return Objects.equals(getName(), other.getName()) && Objects.equals(getReturnType(), other.getReturnType()); } @Override public String toString() { - StringBuilder builder = new StringBuilder(); + final StringBuilder builder = new StringBuilder(); builder.append("MethodSignatureImpl [name="); builder.append(getName()); builder.append(", comment="); diff --git a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/AbstractTypeMemberBuilder.java b/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/AbstractTypeMemberBuilder.java index f3cc5dc410..3a1c3dd52d 100644 --- a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/AbstractTypeMemberBuilder.java +++ b/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/AbstractTypeMemberBuilder.java @@ -39,38 +39,38 @@ abstract class AbstractTypeMemberBuilder> impleme Preconditions.checkArgument(name != null, "Annotation Type cannot have name as null!"); final AnnotationTypeBuilder builder = new AnnotationTypeBuilderImpl(packageName, name); - annotationBuilders = LazyCollections.lazyAdd(annotationBuilders, builder); + this.annotationBuilders = LazyCollections.lazyAdd(this.annotationBuilders, builder); return builder; } protected Type getReturnType() { - return returnType; + return this.returnType; } protected Iterable getAnnotationBuilders() { - return annotationBuilders; + return this.annotationBuilders; } protected String getComment() { - return comment; + return this.comment; } protected boolean isFinal() { - return isFinal; + return this.isFinal; } protected boolean isStatic() { - return isStatic; + return this.isStatic; } @Override public AccessModifier getAccessModifier() { - return accessModifier; + return this.accessModifier; } @Override public String getName() { - return name; + return this.name; } protected abstract T thisInstance(); @@ -125,8 +125,8 @@ abstract class AbstractTypeMemberBuilder> impleme public int hashCode() { final int prime = 31; int result = 1; - result = prime * result + Objects.hashCode(getName()); - result = prime * result + Objects.hashCode(getReturnType()); + result = (prime * result) + Objects.hashCode(getName()); + result = (prime * result) + Objects.hashCode(getReturnType()); return result; } @@ -141,13 +141,13 @@ abstract class AbstractTypeMemberBuilder> impleme if (getClass() != obj.getClass()) { return false; } - AbstractTypeMemberBuilder other = (AbstractTypeMemberBuilder) obj; + final AbstractTypeMemberBuilder other = (AbstractTypeMemberBuilder) obj; return Objects.equals(getName(), other.getName()) && Objects.equals(getReturnType(), other.getReturnType()); } @Override public String toString() { - StringBuilder builder = new StringBuilder(); + final StringBuilder builder = new StringBuilder(); builder.append("GeneratedPropertyImpl [name="); builder.append(getName()); builder.append(", annotations="); diff --git a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/AnnotationTypeBuilderImpl.java b/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/AnnotationTypeBuilderImpl.java index f044f163ba..3cb70d362d 100644 --- a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/AnnotationTypeBuilderImpl.java +++ b/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/AnnotationTypeBuilderImpl.java @@ -32,10 +32,10 @@ final class AnnotationTypeBuilderImpl extends AbstractBaseType implements Annota @Override public AnnotationTypeBuilder addAnnotation(final String packageName, final String name) { - if (packageName != null && name != null) { + if ((packageName != null) && (name != null)) { final AnnotationTypeBuilder builder = new AnnotationTypeBuilderImpl(packageName, name); - if (!annotationBuilders.contains(builder)) { - annotationBuilders = LazyCollections.lazyAdd(annotationBuilders, builder); + if (!this.annotationBuilders.contains(builder)) { + this.annotationBuilders = LazyCollections.lazyAdd(this.annotationBuilders, builder); return builder; } } @@ -43,8 +43,8 @@ final class AnnotationTypeBuilderImpl extends AbstractBaseType implements Annota } private boolean addParameter(final ParameterImpl param) { - if (!parameters.contains(param)) { - parameters = LazyCollections.lazyAdd(parameters, param); + if (!this.parameters.contains(param)) { + this.parameters = LazyCollections.lazyAdd(this.parameters, param); return true; } else { return false; @@ -53,7 +53,7 @@ final class AnnotationTypeBuilderImpl extends AbstractBaseType implements Annota @Override public boolean addParameter(final String paramName, final String value) { - if (paramName != null && value != null) { + if ((paramName != null) && (value != null)) { final ParameterImpl param = new ParameterImpl(paramName, value); return addParameter(param); } @@ -62,7 +62,7 @@ final class AnnotationTypeBuilderImpl extends AbstractBaseType implements Annota @Override public boolean addParameters(final String paramName, final List values) { - if (paramName != null && values != null) { + if ((paramName != null) && (values != null)) { final ParameterImpl param = new ParameterImpl(paramName, values); return addParameter(param); } @@ -71,15 +71,15 @@ final class AnnotationTypeBuilderImpl extends AbstractBaseType implements Annota @Override public AnnotationType toInstance() { - return new AnnotationTypeImpl(packageName, name, annotationBuilders, parameters); + return new AnnotationTypeImpl(this.packageName, this.name, this.annotationBuilders, this.parameters); } @Override public int hashCode() { final int prime = 31; int result = 1; - result = prime * result + Objects.hashCode(name); - result = prime * result + Objects.hashCode(packageName); + result = (prime * result) + Objects.hashCode(this.name); + result = (prime * result) + Objects.hashCode(this.packageName); return result; } @@ -94,21 +94,21 @@ final class AnnotationTypeBuilderImpl extends AbstractBaseType implements Annota if (getClass() != obj.getClass()) { return false; } - AnnotationTypeBuilderImpl other = (AnnotationTypeBuilderImpl) obj; - return Objects.equals(name, other.name) && Objects.equals(packageName, other.packageName); + final AnnotationTypeBuilderImpl other = (AnnotationTypeBuilderImpl) obj; + return Objects.equals(this.name, other.name) && Objects.equals(this.packageName, other.packageName); } @Override public String toString() { - StringBuilder builder = new StringBuilder(); + final StringBuilder builder = new StringBuilder(); builder.append("AnnotationTypeBuilder [packageName="); - builder.append(packageName); + builder.append(this.packageName); builder.append(", name="); - builder.append(name); + builder.append(this.name); builder.append(", annotationBuilders="); - builder.append(annotationBuilders); + builder.append(this.annotationBuilders); builder.append(", parameters="); - builder.append(parameters); + builder.append(this.parameters); builder.append("]"); return builder.toString(); } @@ -146,28 +146,28 @@ final class AnnotationTypeBuilderImpl extends AbstractBaseType implements Annota @Override public String getPackageName() { - return packageName; + return this.packageName; } @Override public String getName() { - return name; + return this.name; } @Override public String getFullyQualifiedName() { - return packageName + "." + name; + return this.packageName + "." + this.name; } @Override public List getAnnotations() { - return annotations; + return this.annotations; } @Override public Parameter getParameter(final String paramName) { if (paramName != null) { - for (final AnnotationType.Parameter parameter : parameters) { + for (final AnnotationType.Parameter parameter : this.parameters) { if (parameter.getName().equals(paramName)) { return parameter; } @@ -178,25 +178,25 @@ final class AnnotationTypeBuilderImpl extends AbstractBaseType implements Annota @Override public List getParameters() { - return parameters; + return this.parameters; } @Override public List getParameterNames() { - return paramNames; + return this.paramNames; } @Override public boolean containsParameters() { - return !parameters.isEmpty(); + return !this.parameters.isEmpty(); } @Override public int hashCode() { final int prime = 31; int result = 1; - result = prime * result + Objects.hashCode(name); - result = prime * result + Objects.hashCode(packageName); + result = (prime * result) + Objects.hashCode(this.name); + result = (prime * result) + Objects.hashCode(this.packageName); return result; } @@ -211,21 +211,21 @@ final class AnnotationTypeBuilderImpl extends AbstractBaseType implements Annota if (getClass() != obj.getClass()) { return false; } - AnnotationTypeImpl other = (AnnotationTypeImpl) obj; - return Objects.equals(name, other.name) && Objects.equals(packageName, other.packageName); + final AnnotationTypeImpl other = (AnnotationTypeImpl) obj; + return Objects.equals(this.name, other.name) && Objects.equals(this.packageName, other.packageName); } @Override public String toString() { - StringBuilder builder = new StringBuilder(); + final StringBuilder builder = new StringBuilder(); builder.append("AnnotationType [packageName="); - builder.append(packageName); + builder.append(this.packageName); builder.append(", name="); - builder.append(name); + builder.append(this.name); builder.append(", annotations="); - builder.append(annotations); + builder.append(this.annotations); builder.append(", parameters="); - builder.append(parameters); + builder.append(this.parameters); builder.append("]"); return builder.toString(); } @@ -253,24 +253,24 @@ final class AnnotationTypeBuilderImpl extends AbstractBaseType implements Annota @Override public String getName() { - return name; + return this.name; } @Override public String getValue() { - return value; + return this.value; } @Override public List getValues() { - return values; + return this.values; } @Override public int hashCode() { final int prime = 31; int result = 1; - result = prime * result + Objects.hashCode(name); + result = (prime * result) + Objects.hashCode(this.name); return result; } @@ -285,19 +285,19 @@ final class AnnotationTypeBuilderImpl extends AbstractBaseType implements Annota if (getClass() != obj.getClass()) { return false; } - ParameterImpl other = (ParameterImpl) obj; - return Objects.equals(name, other.name); + final ParameterImpl other = (ParameterImpl) obj; + return Objects.equals(this.name, other.name); } @Override public String toString() { - StringBuilder builder = new StringBuilder(); + final StringBuilder builder = new StringBuilder(); builder.append("ParameterImpl [name="); - builder.append(name); + builder.append(this.name); builder.append(", value="); - builder.append(value); + builder.append(this.value); builder.append(", values="); - builder.append(values); + builder.append(this.values); builder.append("]"); return builder.toString(); } diff --git a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/ConstantImpl.java b/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/ConstantImpl.java index 92c1feaa91..a4e724e45b 100644 --- a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/ConstantImpl.java +++ b/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/ConstantImpl.java @@ -28,32 +28,32 @@ final class ConstantImpl implements Constant { @Override public Type getDefiningType() { - return definingType; + return this.definingType; } @Override public Type getType() { - return type; + return this.type; } @Override public String getName() { - return name; + return this.name; } @Override public Object getValue() { - return value; + return this.value; } @Override public String toFormattedString() { - StringBuilder builder = new StringBuilder(); - builder.append(type); + final StringBuilder builder = new StringBuilder(); + builder.append(this.type); builder.append(" "); - builder.append(name); + builder.append(this.name); builder.append(" "); - builder.append(value); + builder.append(this.value); return builder.toString(); } @@ -66,8 +66,8 @@ final class ConstantImpl implements Constant { public int hashCode() { final int prime = 31; int result = 1; - result = prime * result + Objects.hashCode(name); - result = prime * result + Objects.hashCode(type); + result = (prime * result) + Objects.hashCode(this.name); + result = (prime * result) + Objects.hashCode(this.type); return result; } @@ -87,24 +87,24 @@ final class ConstantImpl implements Constant { if (getClass() != obj.getClass()) { return false; } - ConstantImpl other = (ConstantImpl) obj; - return Objects.equals(name, other.name) && Objects.equals(type, other.type) && Objects.equals(value, other.value); + final ConstantImpl other = (ConstantImpl) obj; + return Objects.equals(this.name, other.name) && Objects.equals(this.type, other.type) && Objects.equals(this.value, other.value); } @Override public String toString() { - StringBuilder builder = new StringBuilder(); + final StringBuilder builder = new StringBuilder(); builder.append("Constant [type="); - builder.append(type); + builder.append(this.type); builder.append(", name="); - builder.append(name); + builder.append(this.name); builder.append(", value="); - builder.append(value); - if (definingType != null) { + builder.append(this.value); + if (this.definingType != null) { builder.append(", definingType="); - builder.append(definingType.getPackageName()); + builder.append(this.definingType.getPackageName()); builder.append("."); - builder.append(definingType.getName()); + builder.append(this.definingType.getName()); } else { builder.append(", definingType= null"); } diff --git a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/EnumerationBuilderImpl.java b/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/EnumerationBuilderImpl.java index a4596b6513..b158114b59 100644 --- a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/EnumerationBuilderImpl.java +++ b/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/EnumerationBuilderImpl.java @@ -67,10 +67,10 @@ public final class EnumerationBuilderImpl extends AbstractBaseType implements En @Override public AnnotationTypeBuilder addAnnotation(final String packageName, final String name) { - if (packageName != null && name != null) { + if ((packageName != null) && (name != null)) { final AnnotationTypeBuilder builder = new AnnotationTypeBuilderImpl(packageName, name); - if (!annotationBuilders.contains(builder)) { - annotationBuilders = LazyCollections.lazyAdd(annotationBuilders, builder); + if (!this.annotationBuilders.contains(builder)) { + this.annotationBuilders = LazyCollections.lazyAdd(this.annotationBuilders, builder); return builder; } } @@ -80,14 +80,14 @@ public final class EnumerationBuilderImpl extends AbstractBaseType implements En @Override public void addValue(final String name, final int value, final String description) { final EnumPairImpl p = new EnumPairImpl(name, value, description); - values = LazyCollections.lazyAdd(values, p); - unmodifiableValues = Collections.unmodifiableList(values); + this.values = LazyCollections.lazyAdd(this.values, p); + this.unmodifiableValues = Collections.unmodifiableList(this.values); } @Override public Enumeration toInstance(final Type definingType) { - return new EnumerationImpl(definingType, annotationBuilders, packageName, name, unmodifiableValues, - description, reference, moduleName, schemaPath); + return new EnumerationImpl(definingType, this.annotationBuilders, this.packageName, this.name, this.unmodifiableValues, + this.description, this.reference, this.moduleName, this.schemaPath); } /* @@ -97,13 +97,13 @@ public final class EnumerationBuilderImpl extends AbstractBaseType implements En */ @Override public String toString() { - StringBuilder builder = new StringBuilder(); + final StringBuilder builder = new StringBuilder(); builder.append("EnumerationBuilderImpl [packageName="); - builder.append(packageName); + builder.append(this.packageName); builder.append(", name="); - builder.append(name); + builder.append(this.name); builder.append(", values="); - builder.append(values); + builder.append(this.values); builder.append("]"); return builder.toString(); } @@ -138,17 +138,17 @@ public final class EnumerationBuilderImpl extends AbstractBaseType implements En @Override public String getName() { - return name; + return this.name; } @Override public String getMappedName() { - return mappedName; + return this.mappedName; } @Override public int getValue() { - return value; + return this.value; } /* @@ -160,8 +160,8 @@ public final class EnumerationBuilderImpl extends AbstractBaseType implements En public int hashCode() { final int prime = 31; int result = 1; - result = prime * result + Objects.hashCode(name); - result = prime * result + Objects.hashCode(value); + result = (prime * result) + Objects.hashCode(this.name); + result = (prime * result) + Objects.hashCode(this.value); return result; } @@ -181,8 +181,8 @@ public final class EnumerationBuilderImpl extends AbstractBaseType implements En if (getClass() != obj.getClass()) { return false; } - EnumPairImpl other = (EnumPairImpl) obj; - return Objects.equals(name, other.name) && Objects.equals(value, other.value); + final EnumPairImpl other = (EnumPairImpl) obj; + return Objects.equals(this.name, other.name) && Objects.equals(this.value, other.value); } /* @@ -192,20 +192,20 @@ public final class EnumerationBuilderImpl extends AbstractBaseType implements En */ @Override public String toString() { - StringBuilder builder = new StringBuilder(); + final StringBuilder builder = new StringBuilder(); builder.append("EnumPair [name="); - builder.append(name); + builder.append(this.name); builder.append(", mappedName="); builder.append(getMappedName()); builder.append(", value="); - builder.append(value); + builder.append(this.value); builder.append("]"); return builder.toString(); } @Override public String getDescription() { - return description; + return this.description; } @Override @@ -251,22 +251,22 @@ public final class EnumerationBuilderImpl extends AbstractBaseType implements En @Override public Type getParentType() { - return definingType; + return this.definingType; } @Override public List getValues() { - return values; + return this.values; } @Override public List getAnnotations() { - return annotations; + return this.annotations; } @Override public String toFormattedString() { - StringBuilder builder = new StringBuilder(); + final StringBuilder builder = new StringBuilder(); builder.append("public enum"); builder.append(" "); builder.append(getName()); @@ -274,14 +274,14 @@ public final class EnumerationBuilderImpl extends AbstractBaseType implements En builder.append("\n"); int i = 0; - for (final Enumeration.Pair valPair : values) { + for (final Enumeration.Pair valPair : this.values) { builder.append("\t"); builder.append(" "); builder.append(valPair.getMappedName()); builder.append(" ("); builder.append(valPair.getValue()); - if (i == (values.size() - 1)) { + if (i == (this.values.size() - 1)) { builder.append(" );"); } else { builder.append(" ),"); @@ -299,21 +299,21 @@ public final class EnumerationBuilderImpl extends AbstractBaseType implements En */ @Override public String toString() { - StringBuilder builder = new StringBuilder(); + final StringBuilder builder = new StringBuilder(); builder.append("Enumeration [packageName="); builder.append(getPackageName()); - if (definingType != null) { + if (this.definingType != null) { builder.append(", definingType="); - builder.append(definingType.getPackageName()); + builder.append(this.definingType.getPackageName()); builder.append("."); - builder.append(definingType.getName()); + builder.append(this.definingType.getName()); } else { builder.append(", definingType= null"); } builder.append(", name="); builder.append(getName()); builder.append(", values="); - builder.append(values); + builder.append(this.values); builder.append("]"); return builder.toString(); } @@ -360,22 +360,22 @@ public final class EnumerationBuilderImpl extends AbstractBaseType implements En @Override public String getDescription() { - return description; + return this.description; } @Override public String getReference() { - return reference; + return this.reference; } @Override public Iterable getSchemaPath() { - return schemaPath; + return this.schemaPath; } @Override public String getModuleName() { - return moduleName; + return this.moduleName; } } } diff --git a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/GeneratedPropertyBuilderImpl.java b/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/GeneratedPropertyBuilderImpl.java index e5abf441bc..25395462a5 100644 --- a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/GeneratedPropertyBuilderImpl.java +++ b/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/GeneratedPropertyBuilderImpl.java @@ -8,7 +8,6 @@ package org.opendaylight.mdsal.binding.generator.util.generated.type.builder; import java.util.List; - import org.opendaylight.mdsal.binding.model.api.AnnotationType; import org.opendaylight.mdsal.binding.model.api.GeneratedProperty; import org.opendaylight.mdsal.binding.model.api.Type; @@ -18,19 +17,19 @@ public final class GeneratedPropertyBuilderImpl extends AbstractTypeMemberBuilde private String value; private boolean isReadOnly; - public GeneratedPropertyBuilderImpl(String name) { + public GeneratedPropertyBuilderImpl(final String name) { super(name); this.isReadOnly = true; } @Override - public GeneratedPropertyBuilderImpl setValue(String value) { + public GeneratedPropertyBuilderImpl setValue(final String value) { this.value = value; return this; } @Override - public GeneratedPropertyBuilderImpl setReadOnly(boolean isReadOnly) { + public GeneratedPropertyBuilderImpl setReadOnly(final boolean isReadOnly) { this.isReadOnly = isReadOnly; return this; } @@ -41,15 +40,15 @@ public final class GeneratedPropertyBuilderImpl extends AbstractTypeMemberBuilde } @Override - public GeneratedProperty toInstance(Type definingType) { + public GeneratedProperty toInstance(final Type definingType) { final List annotations = toAnnotationTypes(); return new GeneratedPropertyImpl(definingType, getName(), annotations, getComment(), getAccessModifier(), - getReturnType(), isFinal(), isStatic(), isReadOnly, value); + getReturnType(), isFinal(), isStatic(), this.isReadOnly, this.value); } @Override public String toString() { - StringBuilder builder = new StringBuilder(); + final StringBuilder builder = new StringBuilder(); builder.append("GeneratedPropertyImpl [name="); builder.append(getName()); builder.append(", annotations="); @@ -61,7 +60,7 @@ public final class GeneratedPropertyBuilderImpl extends AbstractTypeMemberBuilde builder.append(", isFinal="); builder.append(isFinal()); builder.append(", isReadOnly="); - builder.append(isReadOnly); + builder.append(this.isReadOnly); builder.append(", modifier="); builder.append(getAccessModifier()); builder.append("]"); diff --git a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/GeneratedPropertyImpl.java b/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/GeneratedPropertyImpl.java index 139152fb1b..08b87d860a 100644 --- a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/GeneratedPropertyImpl.java +++ b/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/GeneratedPropertyImpl.java @@ -8,18 +8,17 @@ package org.opendaylight.mdsal.binding.generator.util.generated.type.builder; import java.util.List; - import org.opendaylight.mdsal.binding.model.api.AccessModifier; import org.opendaylight.mdsal.binding.model.api.AnnotationType; import org.opendaylight.mdsal.binding.model.api.GeneratedProperty; import org.opendaylight.mdsal.binding.model.api.Type; final class GeneratedPropertyImpl extends AbstractTypeMember implements GeneratedProperty { - private String value; - private boolean isReadOnly; + private final String value; + private final boolean isReadOnly; - public GeneratedPropertyImpl(Type definingType, String name, List annotations, String comment, - AccessModifier accessModifier, Type returnType, boolean isFinal, boolean isStatic, boolean isReadOnly, String value) { + public GeneratedPropertyImpl(final Type definingType, final String name, final List annotations, final String comment, + final AccessModifier accessModifier, final Type returnType, final boolean isFinal, final boolean isStatic, final boolean isReadOnly, final String value) { super(definingType, name, annotations, comment, accessModifier, returnType, isFinal, isStatic); this.value = value; this.isReadOnly = isReadOnly; @@ -27,17 +26,17 @@ final class GeneratedPropertyImpl extends AbstractTypeMember implements Generate @Override public String getValue() { - return value; + return this.value; } @Override public boolean isReadOnly() { - return isReadOnly; + return this.isReadOnly; } @Override public String toString() { - StringBuilder builder = new StringBuilder(); + final StringBuilder builder = new StringBuilder(); builder.append("GeneratedPropertyImpl [name="); builder.append(getName()); builder.append(", annotations="); @@ -57,7 +56,7 @@ final class GeneratedPropertyImpl extends AbstractTypeMember implements Generate builder.append(", isFinal="); builder.append(isFinal()); builder.append(", isReadOnly="); - builder.append(isReadOnly); + builder.append(this.isReadOnly); builder.append(", modifier="); builder.append(getAccessModifier()); builder.append("]"); diff --git a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/GeneratedTOBuilderImpl.java b/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/GeneratedTOBuilderImpl.java index 47a7950ce2..0a8fc8b531 100644 --- a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/GeneratedTOBuilderImpl.java +++ b/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/GeneratedTOBuilderImpl.java @@ -47,7 +47,7 @@ public final class GeneratedTOBuilderImpl extends AbstractGeneratedTypeBuilder getSchemaPath() { - return schemaPath; + return this.schemaPath; } @Override public String getModuleName() { - return moduleName; + return this.moduleName; } } } diff --git a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/GeneratedTypeBuilderImpl.java b/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/GeneratedTypeBuilderImpl.java index 09057f5ac5..ce48cb9601 100644 --- a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/GeneratedTypeBuilderImpl.java +++ b/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/GeneratedTypeBuilderImpl.java @@ -30,28 +30,28 @@ public final class GeneratedTypeBuilderImpl extends AbstractGeneratedTypeBuilder } @Override - public void setDescription(String description) { + public void setDescription(final String description) { this.description = description; } @Override - public void setModuleName(String moduleName) { + public void setModuleName(final String moduleName) { this.moduleName = moduleName; } @Override - public void setSchemaPath(Iterable schemaPath) { + public void setSchemaPath(final Iterable schemaPath) { this.schemaPath = schemaPath; } @Override - public void setReference(String reference) { + public void setReference(final String reference) { this.reference = reference; } @Override public String toString() { - StringBuilder builder = new StringBuilder(); + final StringBuilder builder = new StringBuilder(); builder.append("GeneratedTransferObject [packageName="); builder.append(getPackageName()); builder.append(", name="); @@ -87,7 +87,7 @@ public final class GeneratedTypeBuilderImpl extends AbstractGeneratedTypeBuilder private final String moduleName; private final Iterable schemaPath; - public GeneratedTypeImpl(GeneratedTypeBuilderImpl builder) { + public GeneratedTypeImpl(final GeneratedTypeBuilderImpl builder) { super(builder); this.description = builder.description; @@ -98,22 +98,22 @@ public final class GeneratedTypeBuilderImpl extends AbstractGeneratedTypeBuilder @Override public String getDescription() { - return description; + return this.description; } @Override public String getReference() { - return reference; + return this.reference; } @Override public Iterable getSchemaPath() { - return schemaPath; + return this.schemaPath; } @Override public String getModuleName() { - return moduleName; + return this.moduleName; } } } diff --git a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/MethodParameterImpl.java b/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/MethodParameterImpl.java index 682e0fa597..068ab9cff5 100644 --- a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/MethodParameterImpl.java +++ b/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/MethodParameterImpl.java @@ -24,12 +24,12 @@ final class MethodParameterImpl implements Parameter { @Override public String getName() { - return name; + return this.name; } @Override public Type getType() { - return type; + return this.type; } /* @@ -41,8 +41,8 @@ final class MethodParameterImpl implements Parameter { public int hashCode() { final int prime = 31; int result = 1; - result = prime * result + Objects.hashCode(name); - result = prime * result + Objects.hashCode(type); + result = (prime * result) + Objects.hashCode(this.name); + result = (prime * result) + Objects.hashCode(this.type); return result; } @@ -62,8 +62,8 @@ final class MethodParameterImpl implements Parameter { if (getClass() != obj.getClass()) { return false; } - MethodParameterImpl other = (MethodParameterImpl) obj; - return Objects.equals(name, other.name) && Objects.equals(type, other.type); + final MethodParameterImpl other = (MethodParameterImpl) obj; + return Objects.equals(this.name, other.name) && Objects.equals(this.type, other.type); } /* @@ -73,13 +73,13 @@ final class MethodParameterImpl implements Parameter { */ @Override public String toString() { - StringBuilder builder = new StringBuilder(); + final StringBuilder builder = new StringBuilder(); builder.append("MethodParameter [name="); - builder.append(name); + builder.append(this.name); builder.append(", type="); - builder.append(type.getPackageName()); + builder.append(this.type.getPackageName()); builder.append("."); - builder.append(type.getName()); + builder.append(this.type.getName()); builder.append("]"); return builder.toString(); } diff --git a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/MethodSignatureBuilderImpl.java b/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/MethodSignatureBuilderImpl.java index aa17fc8482..994d2bc8d0 100644 --- a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/MethodSignatureBuilderImpl.java +++ b/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/generator/util/generated/type/builder/MethodSignatureBuilderImpl.java @@ -34,8 +34,8 @@ final class MethodSignatureBuilderImpl extends AbstractTypeMemberBuilder annotations = toAnnotationTypes(); return new MethodSignatureImpl(definingType, getName(), annotations, getComment(), getAccessModifier(), - getReturnType(), unmodifiableParams, isFinal(), isAbstract, isStatic()); + getReturnType(), this.unmodifiableParams, isFinal(), this.isAbstract, isStatic()); } @Override public int hashCode() { final int prime = 31; int result = 1; - result = prime * result + Objects.hashCode(getName()); - result = prime * result + Objects.hashCode(parameters); - result = prime * result + Objects.hashCode(getReturnType()); + result = (prime * result) + Objects.hashCode(getName()); + result = (prime * result) + Objects.hashCode(this.parameters); + result = (prime * result) + Objects.hashCode(getReturnType()); return result; } @@ -72,11 +72,11 @@ final class MethodSignatureBuilderImpl extends AbstractTypeMemberBuilderTypes - * - * @deprecated Use {@link org.opendaylight.mdsal.binding.generator.util.AbstractBaseType} instead. - */ -@Deprecated -public class AbstractBaseType implements Type { - - /** - * Name of the package to which this Type belongs. - */ - private final String packageName; - - /** - * Name of this Type. - */ - private final String name; - - @Override - public String getPackageName() { - return packageName; - } - - @Override - public String getName() { - return name; - } - - @Override - public String getFullyQualifiedName() { - if (packageName.isEmpty()) { - return name; - } else { - return packageName + "." + name; - } - } - - /** - * Constructs the instance of this class with the concrete package name type - * name. - * - * @param pkName - * string with the package name to which this Type - * belongs - * @param name - * string with the name for this Type - */ - protected AbstractBaseType(final String pkName, final String name) { - if (pkName == null) { - throw new IllegalArgumentException("Package Name for Generated Type cannot be null!"); - } - if (name == null) { - throw new IllegalArgumentException("Name of Generated Type cannot be null!"); - } - this.packageName = pkName; - this.name = name; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + Objects.hashCode(name); - result = prime * result + Objects.hashCode(packageName); - return result; - } - - @Override - public boolean equals(final Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (!(obj instanceof Type)) { - return false; - } - Type other = (Type) obj; - return Objects.equals(name, other.getName()) && Objects.equals(packageName, other.getPackageName()); - } - - @Override - public String toString() { - if (packageName.isEmpty()) { - return "Type (" + name + ")"; - } - return "Type (" + packageName + "." + name + ")"; - } -} diff --git a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/BindingGeneratorUtil.java b/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/BindingGeneratorUtil.java deleted file mode 100644 index 5e8ab2a7d2..0000000000 --- a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/BindingGeneratorUtil.java +++ /dev/null @@ -1,645 +0,0 @@ -/* - * Copyright (c) 2014 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.yangtools.binding.generator.util; - -import com.google.common.base.CharMatcher; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableList.Builder; -import com.google.common.collect.Iterables; -import java.io.ByteArrayOutputStream; -import java.io.DataOutputStream; -import java.io.IOException; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Comparator; -import java.util.Iterator; -import java.util.List; -import org.opendaylight.mdsal.binding.model.api.AccessModifier; -import org.opendaylight.mdsal.binding.model.api.Restrictions; -import org.opendaylight.mdsal.binding.model.api.Type; -import org.opendaylight.mdsal.binding.model.api.type.builder.GeneratedPropertyBuilder; -import org.opendaylight.mdsal.binding.model.api.type.builder.GeneratedTypeBuilderBase; -import org.opendaylight.mdsal.binding.model.api.type.builder.MethodSignatureBuilder; -import org.opendaylight.mdsal.binding.model.api.type.builder.TypeMemberBuilder; -import org.opendaylight.yangtools.yang.binding.BindingMapping; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.common.QNameModule; -import org.opendaylight.yangtools.yang.model.api.Module; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; -import org.opendaylight.yangtools.yang.model.api.TypeDefinition; -import org.opendaylight.yangtools.yang.model.api.type.BinaryTypeDefinition; -import org.opendaylight.yangtools.yang.model.api.type.DecimalTypeDefinition; -import org.opendaylight.yangtools.yang.model.api.type.IntegerTypeDefinition; -import org.opendaylight.yangtools.yang.model.api.type.LengthConstraint; -import org.opendaylight.yangtools.yang.model.api.type.PatternConstraint; -import org.opendaylight.yangtools.yang.model.api.type.RangeConstraint; -import org.opendaylight.yangtools.yang.model.api.type.StringTypeDefinition; -import org.opendaylight.yangtools.yang.model.api.type.UnsignedIntegerTypeDefinition; -import org.opendaylight.yangtools.yang.model.util.type.BaseTypes; -import org.opendaylight.yangtools.yang.model.util.type.DecimalTypeBuilder; - -/** - * Contains the methods for converting strings to valid JAVA language strings - * (package names, class names, attribute names) and to valid javadoc comments. - * - * @deprecated Use {@link org.opendaylight.mdsal.binding.generator.util.BindingGeneratorUtil} instead. - */ -@Deprecated -public final class BindingGeneratorUtil { - - /** - * Impossible to instantiate this class. All of the methods or attributes - * are static. - */ - private BindingGeneratorUtil() { - } - - /** - * Pre-compiled replacement pattern. - */ - private static final CharMatcher DOT_MATCHER = CharMatcher.is('.'); - private static final CharMatcher DASH_COLON_MATCHER = CharMatcher.anyOf("-:"); - private static final CharMatcher GT_MATCHER = CharMatcher.is('>'); - private static final CharMatcher LT_MATCHER = CharMatcher.is('<'); - - private static final Restrictions EMPTY_RESTRICTIONS = new Restrictions() { - @Override - public List getLengthConstraints() { - return Collections.emptyList(); - } - - @Override - public List getPatternConstraints() { - return Collections.emptyList(); - } - - @Override - public List getRangeConstraints() { - return Collections.emptyList(); - } - - @Override - public boolean isEmpty() { - return true; - } - }; - - private static final Comparator> SUID_MEMBER_COMPARATOR = - (o1, o2) -> o1.getName().compareTo(o2.getName()); - - private static final Comparator SUID_NAME_COMPARATOR = - (o1, o2) -> o1.getFullyQualifiedName().compareTo(o2.getFullyQualifiedName()); - - /** - * Converts parameterName to valid JAVA parameter name. - * - * If the parameterName is one of the JAVA reserved words then - * it is prefixed with underscore character. - * - * @param parameterName - * string with the parameter name - * @return string with the admissible parameter name - */ - public static String resolveJavaReservedWordEquivalency(final String parameterName) { - if (parameterName != null && BindingMapping.JAVA_RESERVED_WORDS.contains(parameterName)) { - return "_" + parameterName; - } - return parameterName; - } - - /** - * Converts module name to valid JAVA package name. - * - * The package name consists of: - *
    - *
  • prefix - org.opendaylight.yang.gen.v
  • - *
  • module YANG version - org.opendaylight.yang.gen.v
  • - *
  • module namespace - invalid characters are replaced with dots
  • - *
  • revision prefix - .rev
  • - *
  • revision - YYYYMMDD (MM and DD aren't spread to the whole length)
  • - *
- * - * @param module - * module which contains data about namespace and revision date - * @return string with the valid JAVA package name - * @throws IllegalArgumentException - * if the revision date of the module equals - * null - * @deprecated USe {@link BindingMapping#getRootPackageName(QNameModule)} with {@link Module#getQNameModule()}. - */ - @Deprecated - public static String moduleNamespaceToPackageName(final Module module) { - return BindingMapping.getRootPackageName(module.getQNameModule()); - } - - /** - * Creates package name from specified basePackageName (package - * name for module) and schemaPath. - * - * Resulting package name is concatenation of basePackageName - * and all local names of YANG nodes which are parents of some node for - * which schemaPath is specified. - * - * @param basePackageName - * string with package name of the module, MUST be normalized, - * otherwise this method may return an invalid string. - * @param schemaPath - * list of names of YANG nodes which are parents of some node + - * name of this node - * @return string with valid JAVA package name - * @throws NullPointerException if any of the arguments are null - */ - public static String packageNameForGeneratedType(final String basePackageName, final SchemaPath schemaPath) { - final int size = Iterables.size(schemaPath.getPathTowardsRoot()) - 1; - if (size <= 0) { - return basePackageName; - } - - return generateNormalizedPackageName(basePackageName, schemaPath.getPathFromRoot(), size); - } - - /** - * Creates package name from specified basePackageName (package - * name for module) and schemaPath which crosses an augmentation. - * - * Resulting package name is concatenation of basePackageName - * and all local names of YANG nodes which are parents of some node for - * which schemaPath is specified. - * - * @param basePackageName - * string with package name of the module, MUST be normalized, - * otherwise this method may return an invalid string. - * @param schemaPath - * list of names of YANG nodes which are parents of some node + - * name of this node - * @return string with valid JAVA package name - * @throws NullPointerException if any of the arguments are null - */ - public static String packageNameForAugmentedGeneratedType(final String basePackageName, final SchemaPath schemaPath) { - final int size = Iterables.size(schemaPath.getPathTowardsRoot()); - if (size == 0) { - return basePackageName; - } - - return generateNormalizedPackageName(basePackageName, schemaPath.getPathFromRoot(), size); - } - - private static String generateNormalizedPackageName(final String base, final Iterable path, final int size) { - final StringBuilder builder = new StringBuilder(base); - final Iterator iterator = path.iterator(); - for (int i = 0; i < size; ++i) { - builder.append('.'); - String nodeLocalName = iterator.next().getLocalName(); - // FIXME: Collon ":" is invalid in node local name as per RFC6020, identifier statement. - builder.append(DASH_COLON_MATCHER.replaceFrom(nodeLocalName, '.')); - } - return BindingMapping.normalizePackageName(builder.toString()); - } - - /** - * Creates package name from specified basePackageName (package - * name for module) and schemaPath. - * - * Resulting package name is concatenation of basePackageName - * and all local names of YANG nodes which are parents of some node for - * which schemaPath is specified. - * - * @param basePackageName - * string with package name of the module - * @param schemaPath - * list of names of YANG nodes which are parents of some node + - * name of this node - * @param isUsesAugment - * boolean true if using augment - * @return string with valid JAVA package name - * - * @deprecated Use {@link #packageNameForGeneratedType(String, SchemaPath)} or - * {@link #packageNameForAugmentedGeneratedType(String, SchemaPath)} instead. - */ - @Deprecated - public static String packageNameForGeneratedType(final String basePackageName, final SchemaPath schemaPath, - final boolean isUsesAugment) { - if (basePackageName == null) { - throw new IllegalArgumentException("Base Package Name cannot be NULL!"); - } - if (schemaPath == null) { - throw new IllegalArgumentException("Schema Path cannot be NULL!"); - } - - final Iterable iterable = schemaPath.getPathFromRoot(); - final int size = Iterables.size(iterable); - final int traversalSteps; - if (isUsesAugment) { - traversalSteps = size; - } else { - traversalSteps = size - 1; - } - - if (traversalSteps == 0) { - return BindingMapping.normalizePackageName(basePackageName); - } - - return generateNormalizedPackageName(basePackageName, iterable, traversalSteps); - } - - /** - * Generates the package name for type definition from - * typeDefinition and basePackageName. - * - * @param basePackageName - * string with the package name of the module - * @param typeDefinition - * type definition for which the package name will be generated * - * @return string with valid JAVA package name - * @throws IllegalArgumentException - *
    - *
  • if basePackageName equals null
  • - *
  • if typeDefinition equals null
  • - *
- * @deprecated This method ignores typeDefinition argument and its result is only - * BindingMapping.normalizePackageName(basePackageName). - * Aside from tests, there is not a single user in OpenDaylight codebase, - * hence it can be considered buggy and defunct. It is scheduled for removal - * in Boron release. - */ - @Deprecated - public static String packageNameForTypeDefinition(final String basePackageName, - final TypeDefinition typeDefinition) { - if (basePackageName == null) { - throw new IllegalArgumentException("Base Package Name cannot be NULL!"); - } - if (typeDefinition == null) { - throw new IllegalArgumentException("Type Definition reference cannot be NULL!"); - } - - return BindingMapping.normalizePackageName(basePackageName); - } - - /** - * Converts token to string which is in accordance with best - * practices for JAVA class names. - * - * @param token - * string which contains characters which should be converted to - * JAVA class name - * @return string which is in accordance with best practices for JAVA class - * name. - * - * @deprecated Use {@link BindingMapping#getClassName(QName)} instead. - */ - @Deprecated - public static String parseToClassName(final String token) { - return parseToCamelCase(token, true); - } - - /** - * Converts token to string which is in accordance with best - * practices for JAVA parameter names. - * - * @param token - * string which contains characters which should be converted to - * JAVA parameter name - * @return string which is in accordance with best practices for JAVA - * parameter name. - * - * @deprecated Use {@link BindingMapping#getPropertyName(String)} instead. - */ - @Deprecated public static String parseToValidParamName(final String token) { - return resolveJavaReservedWordEquivalency(parseToCamelCase(token, false)); - } - - /** - * - * Converts string token to the cammel case format. - * - * @param token - * string which should be converted to the cammel case format - * @param uppercase - * boolean value which says whether the first character of the - * token should|shuldn't be uppercased - * @return string in the cammel case format - * @throws IllegalArgumentException - *
    - *
  • if token without white spaces is empty
  • - *
  • if token equals null
  • - *
- */ - private static String parseToCamelCase(final String token, final boolean uppercase) { - if (token == null) { - throw new IllegalArgumentException("Name can not be null"); - } - - String correctStr = DOT_MATCHER.removeFrom(token.trim()); - if (correctStr.isEmpty()) { - throw new IllegalArgumentException("Name can not be empty"); - } - - correctStr = replaceWithCamelCase(correctStr, ' '); - correctStr = replaceWithCamelCase(correctStr, '-'); - correctStr = replaceWithCamelCase(correctStr, '_'); - - char firstChar = correctStr.charAt(0); - firstChar = uppercase ? Character.toUpperCase(firstChar) : Character.toLowerCase(firstChar); - - if (firstChar >= '0' && firstChar <= '9') { - return '_' + correctStr; - } else { - return firstChar + correctStr.substring(1); - } - } - - /** - * Replaces all the occurrences of the removalChar in the - * text with empty string and converts following character to - * upper case. - * - * @param text - * string with source text which should be converted - * @param removalChar - * character which is sought in the text - * @return string which doesn't contain removalChar and has - * following characters converted to upper case - * @throws IllegalArgumentException - * if the length of the returning string has length 0 - */ - private static String replaceWithCamelCase(final String text, final char removalChar) { - int toBeRemovedPos = text.indexOf(removalChar); - if (toBeRemovedPos == -1) { - return text; - } - - StringBuilder sb = new StringBuilder(text); - String toBeRemoved = String.valueOf(removalChar); - do { - sb.replace(toBeRemovedPos, toBeRemovedPos + 1, ""); - // check if 'toBeRemoved' character is not the only character in - // 'text' - if (sb.length() == 0) { - throw new IllegalArgumentException("The resulting string can not be empty"); - } - char replacement = Character.toUpperCase(sb.charAt(toBeRemovedPos)); - sb.setCharAt(toBeRemovedPos, replacement); - toBeRemovedPos = sb.indexOf(toBeRemoved); - } while (toBeRemovedPos != -1); - - return sb.toString(); - } - - private static Iterable sortedCollection(final Comparator comparator, final Collection input) { - if (input.size() > 1) { - final List ret = new ArrayList<>(input); - Collections.sort(ret, comparator); - return ret; - } else { - return input; - } - } - - private static final ThreadLocal SHA1_MD = new ThreadLocal() { - @Override - protected MessageDigest initialValue() { - try { - return MessageDigest.getInstance("SHA"); - } catch (NoSuchAlgorithmException e) { - throw new IllegalStateException("Failed to get a SHA digest provider", e); - } - } - }; - - public static long computeDefaultSUID(final GeneratedTypeBuilderBase to) { - final ByteArrayOutputStream bout = new ByteArrayOutputStream(); - try (final DataOutputStream dout = new DataOutputStream(bout)) { - dout.writeUTF(to.getName()); - dout.writeInt(to.isAbstract() ? 3 : 7); - - for (Type ifc : sortedCollection(SUID_NAME_COMPARATOR, to.getImplementsTypes())) { - dout.writeUTF(ifc.getFullyQualifiedName()); - } - - for (GeneratedPropertyBuilder gp : sortedCollection(SUID_MEMBER_COMPARATOR, to.getProperties())) { - dout.writeUTF(gp.getName()); - } - - for (MethodSignatureBuilder m : sortedCollection(SUID_MEMBER_COMPARATOR, to.getMethodDefinitions())) { - if (!(m.getAccessModifier().equals(AccessModifier.PRIVATE))) { - dout.writeUTF(m.getName()); - dout.write(m.getAccessModifier().ordinal()); - } - } - - dout.flush(); - } catch (IOException e) { - throw new IllegalStateException("Failed to hash object " + to, e); - } - - final byte[] hashBytes = SHA1_MD.get().digest(bout.toByteArray()); - long hash = 0; - for (int i = Math.min(hashBytes.length, 8) - 1; i >= 0; i--) { - hash = (hash << 8) | (hashBytes[i] & 0xFF); - } - return hash; - } - - private static List currentOrEmpty(final List current, final List base) { - return current.equals(base) ? ImmutableList.of() : current; - } - - private static boolean containsConstraint(final StringTypeDefinition type, final PatternConstraint constraint) { - for (StringTypeDefinition wlk = type; wlk != null; wlk = wlk.getBaseType()) { - if (wlk.getPatternConstraints().contains(constraint)) { - return true; - } - } - - return false; - } - - private static List uniquePatterns(final StringTypeDefinition type) { - final List constraints = type.getPatternConstraints(); - if (constraints.isEmpty()) { - return constraints; - } - - final Builder builder = ImmutableList.builder(); - boolean filtered = false; - for (PatternConstraint c : constraints) { - if (containsConstraint(type.getBaseType(), c)) { - filtered = true; - } else { - builder.add(c); - } - } - - return filtered ? builder.build() : constraints; - } - - public static Restrictions getRestrictions(final TypeDefinition type) { - // Old parser generated types which actually contained based restrictions, but our code deals with that when - // binding to core Java types. Hence we'll emit empty restrictions for base types. - if (type == null || type.getBaseType() == null) { - // Handling of decimal64 has changed in the new parser. It contains range restrictions applied to the type - // directly, without an extended type. We need to capture such constraints. In order to retain behavior we - // need to analyze the new semantics and see if the constraints have been overridden. To do that we - // instantiate a temporary unconstrained type and compare them. - // - // FIXME: looking at the generated code it looks as though we need to pass the restrictions without - // comparison - if (type instanceof DecimalTypeDefinition) { - final DecimalTypeDefinition decimal = (DecimalTypeDefinition) type; - final DecimalTypeBuilder tmpBuilder = BaseTypes.decimalTypeBuilder(decimal.getPath()); - tmpBuilder.setFractionDigits(decimal.getFractionDigits()); - final DecimalTypeDefinition tmp = tmpBuilder.build(); - - if (!tmp.getRangeConstraints().equals(decimal.getRangeConstraints())) { - return new Restrictions() { - @Override - public boolean isEmpty() { - return false; - } - - @Override - public List getRangeConstraints() { - return decimal.getRangeConstraints(); - } - - @Override - public List getPatternConstraints() { - return ImmutableList.of(); - } - - @Override - public List getLengthConstraints() { - return ImmutableList.of(); - } - }; - } - } - - return EMPTY_RESTRICTIONS; - } - - final List length; - final List pattern; - final List range; - - /* - * Take care of extended types. - * - * Other types which support constraints are check afterwards. There is a slight twist with them, as returned - * constraints are the effective view, e.g. they are inherited from base type. Since the constraint is already - * enforced by the base type, we want to skip them and not perform duplicate checks. - * - * We end up emitting ConcreteType instances for YANG base types, which leads to their constraints not being - * enforced (most notably decimal64). Therefore we need to make sure we do not strip the next-to-last - * restrictions. - * - * FIXME: this probably not the best solution and needs further analysis. - */ - if (type instanceof BinaryTypeDefinition) { - final BinaryTypeDefinition binary = (BinaryTypeDefinition)type; - final BinaryTypeDefinition base = binary.getBaseType(); - if (base != null && base.getBaseType() != null) { - length = currentOrEmpty(binary.getLengthConstraints(), base.getLengthConstraints()); - } else { - length = binary.getLengthConstraints(); - } - - pattern = ImmutableList.of(); - range = ImmutableList.of(); - } else if (type instanceof DecimalTypeDefinition) { - length = ImmutableList.of(); - pattern = ImmutableList.of(); - - final DecimalTypeDefinition decimal = (DecimalTypeDefinition)type; - final DecimalTypeDefinition base = decimal.getBaseType(); - if (base != null && base.getBaseType() != null) { - range = currentOrEmpty(decimal.getRangeConstraints(), base.getRangeConstraints()); - } else { - range = decimal.getRangeConstraints(); - } - } else if (type instanceof IntegerTypeDefinition) { - length = ImmutableList.of(); - pattern = ImmutableList.of(); - - final IntegerTypeDefinition integer = (IntegerTypeDefinition)type; - final IntegerTypeDefinition base = integer.getBaseType(); - if (base != null && base.getBaseType() != null) { - range = currentOrEmpty(integer.getRangeConstraints(), base.getRangeConstraints()); - } else { - range = integer.getRangeConstraints(); - } - } else if (type instanceof StringTypeDefinition) { - final StringTypeDefinition string = (StringTypeDefinition)type; - final StringTypeDefinition base = string.getBaseType(); - if (base != null && base.getBaseType() != null) { - length = currentOrEmpty(string.getLengthConstraints(), base.getLengthConstraints()); - } else { - length = string.getLengthConstraints(); - } - - pattern = uniquePatterns(string); - range = ImmutableList.of(); - } else if (type instanceof UnsignedIntegerTypeDefinition) { - length = ImmutableList.of(); - pattern = ImmutableList.of(); - - final UnsignedIntegerTypeDefinition unsigned = (UnsignedIntegerTypeDefinition)type; - final UnsignedIntegerTypeDefinition base = unsigned.getBaseType(); - if (base != null && base.getBaseType() != null) { - range = currentOrEmpty(unsigned.getRangeConstraints(), base.getRangeConstraints()); - } else { - range = unsigned.getRangeConstraints(); - } - } else { - length = ImmutableList.of(); - pattern = ImmutableList.of(); - range = ImmutableList.of(); - } - - // Now, this may have ended up being empty, too... - if (length.isEmpty() && pattern.isEmpty() && range.isEmpty()) { - return EMPTY_RESTRICTIONS; - } - - // Nope, not empty allocate a holder - return new Restrictions() { - @Override - public List getRangeConstraints() { - return range; - } - @Override - public List getPatternConstraints() { - return pattern; - } - @Override - public List getLengthConstraints() { - return length; - } - @Override - public boolean isEmpty() { - return false; - } - }; - } - - /** - * Encodes angle brackets in yang statement description - * @param description description of a yang statement which is used to generate javadoc comments - * @return string with encoded angle brackets - */ - public static String encodeAngleBrackets(String description) { - if (description != null) { - description = LT_MATCHER.replaceFrom(description, "<"); - description = GT_MATCHER.replaceFrom(description, ">"); - } - return description; - } -} diff --git a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/BindingTypes.java b/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/BindingTypes.java deleted file mode 100644 index b9c17c8d02..0000000000 --- a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/BindingTypes.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2013 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.yangtools.binding.generator.util; - -import static org.opendaylight.yangtools.binding.generator.util.Types.parameterizedTypeFor; -import static org.opendaylight.yangtools.binding.generator.util.Types.typeForClass; -import org.opendaylight.mdsal.binding.model.api.ConcreteType; -import org.opendaylight.mdsal.binding.model.api.ParameterizedType; -import org.opendaylight.mdsal.binding.model.api.Type; -import org.opendaylight.yangtools.yang.binding.Augmentable; -import org.opendaylight.yangtools.yang.binding.Augmentation; -import org.opendaylight.yangtools.yang.binding.BaseIdentity; -import org.opendaylight.yangtools.yang.binding.ChildOf; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.DataRoot; -import org.opendaylight.yangtools.yang.binding.Identifiable; -import org.opendaylight.yangtools.yang.binding.Identifier; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.binding.Notification; -import org.opendaylight.yangtools.yang.binding.NotificationListener; -import org.opendaylight.yangtools.yang.binding.RpcService; - -/** -* @deprecated Use {@link org.opendaylight.mdsal.binding.generator.util.BindingTypes} instead. -*/ -@Deprecated -public final class BindingTypes { - - public static final ConcreteType AUGMENTABLE = typeForClass(Augmentable.class); - public static final ConcreteType AUGMENTATION = typeForClass(Augmentation.class); - public static final ConcreteType BASE_IDENTITY = typeForClass(BaseIdentity.class); - public static final ConcreteType DATA_OBJECT = typeForClass(DataObject.class); - public static final ConcreteType DATA_ROOT = typeForClass(DataRoot.class); - public static final ConcreteType IDENTIFIABLE = typeForClass(Identifiable.class); - public static final ConcreteType IDENTIFIER = typeForClass(Identifier.class); - public static final ConcreteType INSTANCE_IDENTIFIER = typeForClass(InstanceIdentifier.class); - public static final ConcreteType NOTIFICATION = typeForClass(Notification.class); - public static final ConcreteType NOTIFICATION_LISTENER = typeForClass(NotificationListener.class); - public static final ConcreteType RPC_SERVICE = typeForClass(RpcService.class); - - private static final ConcreteType CHILD_OF = typeForClass(ChildOf.class); - - private BindingTypes() { - - } - - public static ParameterizedType augmentable(Type t) { - return parameterizedTypeFor(AUGMENTABLE, t); - } - - public static ParameterizedType childOf(Type t) { - return parameterizedTypeFor(CHILD_OF, t); - } - -} diff --git a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/ReferencedTypeImpl.java b/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/ReferencedTypeImpl.java deleted file mode 100644 index c0f913f77c..0000000000 --- a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/ReferencedTypeImpl.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2013 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.yangtools.binding.generator.util; - -/** - * - * Wraps combination of packageName and name to the - * object representation - * - * @deprecated Use {@link org.opendaylight.mdsal.binding.generator.util.ReferencedTypeImpl} instead. - */ -@Deprecated -public final class ReferencedTypeImpl extends AbstractBaseType { - - /** - * Creates instance of this class with concrete package name and type name - * - * @param packageName - * string with the package name - * @param name - * string with the name for referenced type - */ - public ReferencedTypeImpl(String packageName, String name) { - super(packageName, name); - } - - @Override - public String toString() { - StringBuilder builder = new StringBuilder(); - builder.append("ReferencedTypeImpl [packageName="); - builder.append(getPackageName()); - builder.append(", name="); - builder.append(getName()); - builder.append("]"); - return builder.toString(); - } -} diff --git a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/TypeConstants.java b/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/TypeConstants.java deleted file mode 100644 index 02dbd492de..0000000000 --- a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/TypeConstants.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2014 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.yangtools.binding.generator.util; - -/** - * - * Contains constants used in relations with Type. - * - * @deprecated Use {@link org.opendaylight.mdsal.binding.generator.util.TypeConstants} instead. - */ -@Deprecated -public final class TypeConstants { - - /** - * Name of the class constant which hold list of the regular expression - * strings. - */ - public static final String PATTERN_CONSTANT_NAME = "PATTERN_CONSTANTS"; - - /** - * Creation of new instance is prohibited. - */ - private TypeConstants() { - } -} diff --git a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/Types.java b/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/Types.java deleted file mode 100644 index a124778bd7..0000000000 --- a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/Types.java +++ /dev/null @@ -1,394 +0,0 @@ -/* - * Copyright (c) 2013 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.yangtools.binding.generator.util; - -import com.google.common.base.CharMatcher; -import com.google.common.base.Optional; -import com.google.common.base.Preconditions; -import com.google.common.base.Splitter; -import com.google.common.cache.CacheBuilder; -import com.google.common.cache.CacheLoader; -import com.google.common.cache.LoadingCache; -import com.google.common.collect.Iterables; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.Future; -import javax.annotation.Nullable; -import org.opendaylight.mdsal.binding.model.api.BaseTypeWithRestrictions; -import org.opendaylight.mdsal.binding.model.api.ConcreteType; -import org.opendaylight.mdsal.binding.model.api.ParameterizedType; -import org.opendaylight.mdsal.binding.model.api.Restrictions; -import org.opendaylight.mdsal.binding.model.api.Type; -import org.opendaylight.mdsal.binding.model.api.WildcardType; -import org.opendaylight.yangtools.yang.binding.Augmentable; -import org.opendaylight.yangtools.yang.binding.Augmentation; -import org.opendaylight.yangtools.yang.model.api.type.LengthConstraint; -import org.opendaylight.yangtools.yang.model.api.type.PatternConstraint; -import org.opendaylight.yangtools.yang.model.api.type.RangeConstraint; -import org.opendaylight.yangtools.yang.model.util.BaseConstraints; - -/** - * @deprecated Use {@link org.opendaylight.mdsal.binding.generator.util.Types} instead. - */ -@Deprecated -public final class Types { - private static final CacheLoader, ConcreteType> TYPE_LOADER = - new CacheLoader, ConcreteType>() { - @Override - public ConcreteType load(final Class key) { - return new ConcreteTypeImpl(key.getPackage().getName(), key.getSimpleName(), null); - } - }; - private static final LoadingCache, ConcreteType> TYPE_CACHE = - CacheBuilder.newBuilder().weakKeys().build(TYPE_LOADER); - - private static final Type SET_TYPE = typeForClass(Set.class); - private static final Type LIST_TYPE = typeForClass(List.class); - private static final Type MAP_TYPE = typeForClass(Map.class); - - public static final ConcreteType BOOLEAN = typeForClass(Boolean.class); - public static final ConcreteType FUTURE = typeForClass(Future.class); - public static final ConcreteType STRING = typeForClass(String.class); - public static final ConcreteType VOID = typeForClass(Void.class); - public static final ConcreteType BYTE_ARRAY = primitiveType("byte[]", null); - public static final ConcreteType CHAR_ARRAY = primitiveType("char[]", null); - private static final Splitter DOT_SPLITTER = Splitter.on('.'); - - /** - * It is not desirable to create instance of this class - */ - private Types() { - } - - /** - * Creates the instance of type - * {@link org.opendaylight.mdsal.binding.model.api.ConcreteType - * ConcreteType} which represents JAVA void type. - * - * @return ConcreteType instance which represents JAVA - * void - */ - public static ConcreteType voidType() { - return VOID; - } - - /** - * Creates the instance of type - * {@link org.opendaylight.mdsal.binding.model.api.ConcreteType - * ConcreteType} which represents primitive JAVA type for which package - * doesn't exist. - * - * @param primitiveType - * string containing programmatic construction based on - * primitive type (e.g byte[]) - * @param restrictions - * restrictions object - * @return ConcreteType instance which represents programmatic - * construction with primitive JAVA type - */ - public static ConcreteType primitiveType(final String primitiveType, final Restrictions restrictions) { - return new ConcreteTypeImpl("", primitiveType, restrictions); - } - - /** - * Returns an instance of {@link ConcreteType} describing the class - * - * @param cls - * Class to describe - * @return Description of class - */ - public static ConcreteType typeForClass(final Class cls) { - return TYPE_CACHE.getUnchecked(cls); - } - - public static ConcreteType typeForClass(final Class cls, final Restrictions restrictions) { - if (restrictions != null) { - if (restrictions instanceof DefaultRestrictions) { - return new ConcreteTypeImpl(cls.getPackage().getName(), cls.getSimpleName(), restrictions); - } else { - return new BaseTypeWithRestrictionsImpl(cls.getPackage().getName(), cls.getSimpleName(), restrictions); - } - } else { - return typeForClass(cls); - } - } - - /** - * Returns an instance of {@link ParameterizedType} describing the typed - * {@link Map}<K,V> - * - * @param keyType - * Key Type - * @param valueType - * Value Type - * @return Description of generic type instance - */ - public static ParameterizedType mapTypeFor(final Type keyType, final Type valueType) { - return parameterizedTypeFor(MAP_TYPE, keyType, valueType); - } - - /** - * Returns an instance of {@link ParameterizedType} describing the typed - * {@link Set}<V> with concrete type of value. - * - * @param valueType - * Value Type - * @return Description of generic type instance of Set - */ - public static ParameterizedType setTypeFor(final Type valueType) { - return parameterizedTypeFor(SET_TYPE, valueType); - } - - /** - * Returns an instance of {@link ParameterizedType} describing the typed - * {@link List}<V> with concrete type of value. - * - * @param valueType - * Value Type - * @return Description of type instance of List - */ - public static ParameterizedType listTypeFor(final Type valueType) { - return parameterizedTypeFor(LIST_TYPE, valueType); - } - - /** - * Creates instance of type - * {@link org.opendaylight.mdsal.binding.model.api.ParameterizedType - * ParameterizedType} - * - * @param type - * JAVA Type for raw type - * @param parameters - * JAVA Types for actual parameter types - * @return ParametrizedType reprezentation of type - * and its parameters parameters - */ - public static ParameterizedType parameterizedTypeFor(final Type type, final Type... parameters) { - return new ParametrizedTypeImpl(type, parameters); - } - - /** - * Creates instance of type - * {@link org.opendaylight.mdsal.binding.model.api.WildcardType - * WildcardType} - * - * @param packageName - * string with the package name - * @param typeName - * string with the type name - * @return WildcardType representation of - * packageName and typeName - */ - public static WildcardType wildcardTypeFor(final String packageName, final String typeName) { - return new WildcardTypeImpl(packageName, typeName); - } - - /** - * Creates instance of - * {@link org.opendaylight.mdsal.binding.model.api.ParameterizedType - * ParameterizedType} where raw type is - * {@link org.opendaylight.yangtools.yang.binding.Augmentable} and actual - * parameter is valueType. - * - * @param valueType - * JAVA Type with actual parameter - * @return ParametrizedType representation of raw type - * Augmentable with actual parameter - * valueType - */ - public static ParameterizedType augmentableTypeFor(final Type valueType) { - final Type augmentable = typeForClass(Augmentable.class); - return parameterizedTypeFor(augmentable, valueType); - } - - /** - * Creates instance of - * {@link org.opendaylight.mdsal.binding.model.api.ParameterizedType - * ParameterizedType} where raw type is - * {@link org.opendaylight.yangtools.yang.binding.Augmentation} and actual - * parameter is valueType. - * - * @param valueType - * JAVA Type with actual parameter - * @return ParametrizedType reprezentation of raw type - * Augmentation with actual parameter - * valueType - */ - public static ParameterizedType augmentationTypeFor(final Type valueType) { - final Type augmentation = typeForClass(Augmentation.class); - return parameterizedTypeFor(augmentation, valueType); - } - - - public static @Nullable String getOuterClassName(final Type valueType) { - final String pkgName = valueType.getPackageName(); - if(CharMatcher.JAVA_UPPER_CASE.indexIn(pkgName) >= 0) { - // It is inner class. - return Iterables.getLast(DOT_SPLITTER.split(pkgName)); - } - return null; - } - - /** - * - * Represents concrete JAVA type. - * - */ - private static final class ConcreteTypeImpl extends AbstractBaseType implements ConcreteType { - private final Restrictions restrictions; - - /** - * Creates instance of this class with package pkName and - * with the type name name. - * - * @param pkName - * string with package name - * @param name - * string with the name of the type - */ - private ConcreteTypeImpl(final String pkName, final String name, final Restrictions restrictions) { - super(pkName, name); - this.restrictions = restrictions; - } - - @Override - public Restrictions getRestrictions() { - return restrictions; - } - } - - /** - * - * Represents concrete JAVA type with changed restriction values. - * - */ - private static final class BaseTypeWithRestrictionsImpl extends AbstractBaseType implements BaseTypeWithRestrictions { - private final Restrictions restrictions; - - /** - * Creates instance of this class with package pkName and - * with the type name name. - * - * @param pkName - * string with package name - * @param name - * string with the name of the type - */ - private BaseTypeWithRestrictionsImpl(final String pkName, final String name, final Restrictions restrictions) { - super(pkName, name); - this.restrictions = Preconditions.checkNotNull(restrictions); - } - - @Override - public Restrictions getRestrictions() { - return restrictions; - } - } - - /** - * - * Represents parametrized JAVA type. - * - */ - private static class ParametrizedTypeImpl extends AbstractBaseType implements ParameterizedType { - /** - * Array of JAVA actual type parameters. - */ - private final Type[] actualTypes; - - /** - * JAVA raw type (like List, Set, Map...) - */ - private final Type rawType; - - @Override - public Type[] getActualTypeArguments() { - - return actualTypes; - } - - @Override - public Type getRawType() { - return rawType; - } - - /** - * Creates instance of this class with concrete rawType and array of - * actual parameters. - * - * @param rawType - * JAVA Type for raw type - * @param actTypes - * array of actual parameters - */ - public ParametrizedTypeImpl(final Type rawType, final Type[] actTypes) { - super(rawType.getPackageName(), rawType.getName()); - this.rawType = rawType; - this.actualTypes = actTypes.clone(); - } - - } - - /** - * - * Represents JAVA bounded wildcard type. - * - */ - private static class WildcardTypeImpl extends AbstractBaseType implements WildcardType { - /** - * Creates instance of this class with concrete package and type name. - * - * @param packageName - * string with the package name - * @param typeName - * string with the name of type - */ - public WildcardTypeImpl(final String packageName, final String typeName) { - super(packageName, typeName); - } - } - - public static DefaultRestrictions getDefaultRestrictions(final T min, final T max) { - return new DefaultRestrictions<>(min, max); - } - - private static final class DefaultRestrictions implements Restrictions { - private final T min; - private final T max; - private final List rangeConstraints; - - private DefaultRestrictions(final T min, final T max) { - this.min = Preconditions.checkNotNull(min); - this.max = Preconditions.checkNotNull(max); - this.rangeConstraints = Collections.singletonList(BaseConstraints.newRangeConstraint(min, max, Optional - .absent(), Optional.absent())); - } - - @Override - public boolean isEmpty() { - return false; - } - - @Override - public List getRangeConstraints() { - return rangeConstraints; - } - - @Override - public List getPatternConstraints() { - return Collections.emptyList(); - } - - @Override - public List getLengthConstraints() { - return Collections.emptyList(); - } - } -} \ No newline at end of file diff --git a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/AbstractGeneratedType.java b/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/AbstractGeneratedType.java deleted file mode 100644 index 320949a8aa..0000000000 --- a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/AbstractGeneratedType.java +++ /dev/null @@ -1,218 +0,0 @@ -/* - * Copyright (c) 2013 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.yangtools.binding.generator.util.generated.type.builder; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import org.opendaylight.mdsal.binding.model.api.AnnotationType; -import org.opendaylight.mdsal.binding.model.api.Constant; -import org.opendaylight.mdsal.binding.model.api.Enumeration; -import org.opendaylight.mdsal.binding.model.api.GeneratedProperty; -import org.opendaylight.mdsal.binding.model.api.GeneratedType; -import org.opendaylight.mdsal.binding.model.api.MethodSignature; -import org.opendaylight.mdsal.binding.model.api.Type; -import org.opendaylight.mdsal.binding.model.api.type.builder.AnnotationTypeBuilder; -import org.opendaylight.mdsal.binding.model.api.type.builder.EnumBuilder; -import org.opendaylight.mdsal.binding.model.api.type.builder.GeneratedPropertyBuilder; -import org.opendaylight.mdsal.binding.model.api.type.builder.GeneratedTOBuilder; -import org.opendaylight.mdsal.binding.model.api.type.builder.GeneratedTypeBuilder; -import org.opendaylight.mdsal.binding.model.api.type.builder.MethodSignatureBuilder; -import org.opendaylight.yangtools.binding.generator.util.AbstractBaseType; - -/** - * @deprecated Use {@link org.opendaylight.mdsal.binding.generator.util.generated.type.builder.AbstractGeneratedType} instead. - */ -@Deprecated -abstract class AbstractGeneratedType extends AbstractBaseType implements GeneratedType { - - private final Type parent; - private final String comment; - private final List annotations; - private final List implementsTypes; - private final List enumerations; - private final List constants; - private final List methodSignatures; - private final List enclosedTypes; - private final List properties; - private final boolean isAbstract; - - public AbstractGeneratedType(final AbstractGeneratedTypeBuilder builder) { - super(builder.getPackageName(), builder.getName()); - this.parent = builder.getParent(); - this.comment = builder.getComment(); - this.annotations = toUnmodifiableAnnotations(builder.getAnnotations()); - this.implementsTypes = makeUnmodifiable(builder.getImplementsTypes()); - this.constants = makeUnmodifiable(builder.getConstants()); - this.enumerations = toUnmodifiableEnumerations(builder.getEnumerations()); - this.methodSignatures = toUnmodifiableMethods(builder.getMethodDefinitions()); - this.enclosedTypes = toUnmodifiableEnclosedTypes(builder.getEnclosedTypes(), - builder.getEnclosedTransferObjects()); - this.properties = toUnmodifiableProperties(builder.getProperties()); - this.isAbstract = builder.isAbstract(); - } - - public AbstractGeneratedType(final Type parent, final String packageName, final String name, final String comment, - final List annotationBuilders, final boolean isAbstract, - final List implementsTypes, final List enclosedGenTypeBuilders, - final List enclosedGenTOBuilders, final List enumBuilders, - final List constants, final List methodBuilders, - final List propertyBuilders) { - super(packageName, name); - this.parent = parent; - this.comment = comment; - this.annotations = toUnmodifiableAnnotations(annotationBuilders); - this.implementsTypes = makeUnmodifiable(implementsTypes); - this.constants = makeUnmodifiable(constants); - this.enumerations = toUnmodifiableEnumerations(enumBuilders); - this.methodSignatures = toUnmodifiableMethods(methodBuilders); - this.enclosedTypes = toUnmodifiableEnclosedTypes(enclosedGenTypeBuilders, enclosedGenTOBuilders); - this.properties = toUnmodifiableProperties(propertyBuilders); - this.isAbstract = isAbstract; - } - - protected static final List makeUnmodifiable(final List list) { - switch (list.size()) { - case 0: - return Collections.emptyList(); - case 1: - return Collections.singletonList(list.get(0)); - default: - return Collections.unmodifiableList(list); - } - } - - private static List toUnmodifiableEnclosedTypes(final List enclosedGenTypeBuilders, - final List enclosedGenTOBuilders) { - final ArrayList enclosedTypesList = new ArrayList<>(enclosedGenTypeBuilders.size() + enclosedGenTOBuilders.size()); - for (final GeneratedTypeBuilder builder : enclosedGenTypeBuilders) { - if (builder != null) { - enclosedTypesList.add(builder.toInstance()); - } - } - - for (final GeneratedTOBuilder builder : enclosedGenTOBuilders) { - if (builder != null) { - enclosedTypesList.add(builder.toInstance()); - } - } - - return makeUnmodifiable(enclosedTypesList); - } - - protected static final List toUnmodifiableAnnotations(final List annotationBuilders) { - final List annotationList = new ArrayList<>(annotationBuilders.size()); - for (final AnnotationTypeBuilder builder : annotationBuilders) { - annotationList.add(builder.toInstance()); - } - return makeUnmodifiable(annotationList); - } - - protected final List toUnmodifiableMethods(final List methodBuilders) { - final List methods = new ArrayList<>(methodBuilders.size()); - for (final MethodSignatureBuilder methodBuilder : methodBuilders) { - methods.add(methodBuilder.toInstance(this)); - } - return makeUnmodifiable(methods); - } - - protected final List toUnmodifiableEnumerations(final List enumBuilders) { - final List enums = new ArrayList<>(enumBuilders.size()); - for (final EnumBuilder enumBuilder : enumBuilders) { - enums.add(enumBuilder.toInstance(this)); - } - return makeUnmodifiable(enums); - } - - protected final List toUnmodifiableProperties(final List methodBuilders) { - final List methods = new ArrayList<>(methodBuilders.size()); - for (final GeneratedPropertyBuilder methodBuilder : methodBuilders) { - methods.add(methodBuilder.toInstance(this)); - } - return makeUnmodifiable(methods); - } - - @Override - public final Type getParentType() { - return parent; - } - - @Override - public final String getComment() { - return comment; - } - - @Override - public final List getAnnotations() { - return annotations; - } - - @Override - public final boolean isAbstract() { - return isAbstract; - } - - @Override - public final List getImplements() { - return implementsTypes; - } - - @Override - public final List getEnclosedTypes() { - return enclosedTypes; - } - - @Override - public final List getEnumerations() { - return enumerations; - } - - @Override - public final List getConstantDefinitions() { - return constants; - } - - @Override - public final List getMethodDefinitions() { - return methodSignatures; - } - - @Override - public final List getProperties() { - return properties; - } - - @Override - public String toString() { - StringBuilder builder = new StringBuilder(); - builder.append("GeneratedType [packageName="); - builder.append(getPackageName()); - builder.append(", name="); - builder.append(getName()); - if (parent != null) { - builder.append(", parent="); - builder.append(parent.getFullyQualifiedName()); - } else { - builder.append(", parent=null"); - } - builder.append(", comment="); - builder.append(comment); - builder.append(", annotations="); - builder.append(annotations); - builder.append(", enclosedTypes="); - builder.append(enclosedTypes); - builder.append(", enumerations="); - builder.append(enumerations); - builder.append(", constants="); - builder.append(constants); - builder.append(", methodSignatures="); - builder.append(methodSignatures); - builder.append("]"); - return builder.toString(); - } -} diff --git a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/AbstractGeneratedTypeBuilder.java b/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/AbstractGeneratedTypeBuilder.java deleted file mode 100644 index a9e528cdbb..0000000000 --- a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/AbstractGeneratedTypeBuilder.java +++ /dev/null @@ -1,245 +0,0 @@ -/* - * Copyright (c) 2013 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.yangtools.binding.generator.util.generated.type.builder; - -import com.google.common.base.Preconditions; -import java.util.Collections; -import java.util.List; -import java.util.Objects; -import org.opendaylight.mdsal.binding.model.api.AccessModifier; -import org.opendaylight.mdsal.binding.model.api.Constant; -import org.opendaylight.mdsal.binding.model.api.Type; -import org.opendaylight.mdsal.binding.model.api.type.builder.AnnotationTypeBuilder; -import org.opendaylight.mdsal.binding.model.api.type.builder.EnumBuilder; -import org.opendaylight.mdsal.binding.model.api.type.builder.GeneratedPropertyBuilder; -import org.opendaylight.mdsal.binding.model.api.type.builder.GeneratedTOBuilder; -import org.opendaylight.mdsal.binding.model.api.type.builder.GeneratedTypeBuilder; -import org.opendaylight.mdsal.binding.model.api.type.builder.GeneratedTypeBuilderBase; -import org.opendaylight.mdsal.binding.model.api.type.builder.MethodSignatureBuilder; -import org.opendaylight.yangtools.binding.generator.util.AbstractBaseType; -import org.opendaylight.yangtools.util.LazyCollections; - -/** - * @deprecated Use {org.opendaylight.mdsal.binding.generator.util.generated.type.builder.AbstractGeneratedTypeBuilder} instead. - */ -@Deprecated -abstract class AbstractGeneratedTypeBuilder> extends AbstractBaseType implements GeneratedTypeBuilderBase { - - private List annotationBuilders = Collections.emptyList(); - private List implementsTypes = Collections.emptyList(); - private List enumDefinitions = Collections.emptyList(); - private List constants = Collections.emptyList(); - private List methodDefinitions = Collections.emptyList(); - private final List enclosedTypes = Collections.emptyList(); - private List enclosedTransferObjects = Collections.emptyList(); - private List properties = Collections.emptyList(); - private String comment = ""; - private boolean isAbstract; - - protected AbstractGeneratedTypeBuilder(final String packageName, final String name) { - super(packageName, name); - } - - protected String getComment() { - return comment; - } - - protected List getAnnotations() { - return annotationBuilders; - } - - @Override - public boolean isAbstract() { - return isAbstract; - } - - @Override - public List getImplementsTypes() { - return implementsTypes; - } - - protected List getEnumerations() { - return enumDefinitions; - } - - protected List getConstants() { - return constants; - } - - @Override - public List getMethodDefinitions() { - return methodDefinitions; - } - - protected List getEnclosedTypes() { - return enclosedTypes; - } - - protected List getEnclosedTransferObjects() { - return enclosedTransferObjects; - } - - protected abstract T thisInstance(); - - @Override - public GeneratedTOBuilder addEnclosingTransferObject(final String name) { - Preconditions.checkArgument(name != null, "Name for Enclosing Generated Transfer Object cannot be null!"); - GeneratedTOBuilder builder = new GeneratedTOBuilderImpl(getFullyQualifiedName(), name); - - Preconditions.checkArgument(!enclosedTransferObjects.contains(builder), "This generated type already contains equal enclosing transfer object."); - enclosedTransferObjects = LazyCollections.lazyAdd(enclosedTransferObjects, builder); - return builder; - } - - @Override - public T addEnclosingTransferObject(final GeneratedTOBuilder genTOBuilder) { - Preconditions.checkArgument(genTOBuilder != null, "Parameter genTOBuilder cannot be null!"); - Preconditions.checkArgument(!enclosedTransferObjects.contains(genTOBuilder), "This generated type already contains equal enclosing transfer object."); - enclosedTransferObjects = LazyCollections.lazyAdd(enclosedTransferObjects, genTOBuilder); - return thisInstance(); - } - - @Override - public T addComment(final String comment) { - this.comment = comment; - return thisInstance(); - } - - @Override - public AnnotationTypeBuilder addAnnotation(final String packageName, final String name) { - Preconditions.checkArgument(packageName != null, "Package Name for Annotation Type cannot be null!"); - Preconditions.checkArgument(name != null, "Name of Annotation Type cannot be null!"); - - final AnnotationTypeBuilder builder = new AnnotationTypeBuilderImpl(packageName, name); - - Preconditions.checkArgument(!annotationBuilders.contains(builder), "This generated type already contains equal annotation."); - annotationBuilders = LazyCollections.lazyAdd(annotationBuilders, builder); - return builder; - } - - @Override - public T setAbstract(final boolean isAbstract) { - this.isAbstract = isAbstract; - return thisInstance(); - } - - @Override - public T addImplementsType(final Type genType) { - Preconditions.checkArgument(genType != null, "Type cannot be null"); - Preconditions.checkArgument(!implementsTypes.contains(genType), "This generated type already contains equal implements type."); - implementsTypes = LazyCollections.lazyAdd(implementsTypes, genType); - return thisInstance(); - } - - @Override - public Constant addConstant(final Type type, final String name, final Object value) { - Preconditions.checkArgument(type != null, "Returning Type for Constant cannot be null!"); - Preconditions.checkArgument(name != null, "Name of constant cannot be null!"); - Preconditions.checkArgument(!containsConstant(name), "This generated type already contains constant with the same name."); - - final Constant constant = new ConstantImpl(this, type, name, value); - constants = LazyCollections.lazyAdd(constants, constant); - return constant; - } - - public boolean containsConstant(final String name) { - Preconditions.checkArgument(name != null, "Parameter name can't be null"); - for (Constant constant : constants) { - if (name.equals(constant.getName())) { - return true; - } - } - return false; - } - - @Override - public EnumBuilder addEnumeration(final String name) { - Preconditions.checkArgument(name != null, "Name of enumeration cannot be null!"); - final EnumBuilder builder = new EnumerationBuilderImpl(getFullyQualifiedName(), name); - - Preconditions.checkArgument(!enumDefinitions.contains(builder), "This generated type already contains equal enumeration."); - enumDefinitions = LazyCollections.lazyAdd(enumDefinitions, builder); - return builder; - } - - @Override - public MethodSignatureBuilder addMethod(final String name) { - Preconditions.checkArgument(name != null, "Name of method cannot be null!"); - final MethodSignatureBuilder builder = new MethodSignatureBuilderImpl(name); - builder.setAccessModifier(AccessModifier.PUBLIC); - builder.setAbstract(true); - methodDefinitions = LazyCollections.lazyAdd(methodDefinitions, builder); - return builder; - } - - @Override - public boolean containsMethod(final String name) { - Preconditions.checkArgument(name != null, "Parameter name can't be null"); - for (MethodSignatureBuilder methodDefinition : methodDefinitions) { - if (name.equals(methodDefinition.getName())) { - return true; - } - } - return false; - } - - @Override - public GeneratedPropertyBuilder addProperty(final String name) { - Preconditions.checkArgument(name != null, "Parameter name can't be null"); - Preconditions.checkArgument(!containsProperty(name), "This generated type already contains property with the same name."); - - final GeneratedPropertyBuilder builder = new GeneratedPropertyBuilderImpl(name); - builder.setAccessModifier(AccessModifier.PUBLIC); - properties = LazyCollections.lazyAdd(properties, builder); - return builder; - } - - @Override - public boolean containsProperty(final String name) { - Preconditions.checkArgument(name != null, "Parameter name can't be null"); - for (GeneratedPropertyBuilder property : properties) { - if (name.equals(property.getName())) { - return true; - } - } - return false; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + Objects.hashCode(getName()); - result = prime * result + Objects.hashCode(getPackageName()); - return result; - } - - @Override - public boolean equals(final Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - AbstractGeneratedTypeBuilder other = (AbstractGeneratedTypeBuilder) obj; - return Objects.equals(getName(), other.getName()) && Objects.equals(getPackageName(), other.getPackageName()); - } - - public Type getParent() { - return null; - } - - @Override - public List getProperties() { - return properties; - } -} diff --git a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/AbstractTypeMember.java b/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/AbstractTypeMember.java deleted file mode 100644 index bd05cc334c..0000000000 --- a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/AbstractTypeMember.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright (c) 2013 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.yangtools.binding.generator.util.generated.type.builder; - -import java.util.List; -import java.util.Objects; -import org.opendaylight.mdsal.binding.model.api.AccessModifier; -import org.opendaylight.mdsal.binding.model.api.AnnotationType; -import org.opendaylight.mdsal.binding.model.api.Type; -import org.opendaylight.mdsal.binding.model.api.TypeMember; - -/** - * @deprecated Use {@link org.opendaylight.mdsal.binding.generator.util.generated.type.builder.AbstractTypeMember} instead. - */ -@Deprecated -abstract class AbstractTypeMember implements TypeMember { - - private final String name; - private final String comment; - private final Type definingType; - private final Type returnType; - private final List annotations; - private final boolean isFinal; - private final boolean isStatic; - private final AccessModifier accessModifier; - - protected AbstractTypeMember(final Type definingType, final String name, final List annotations, - final String comment, final AccessModifier accessModifier, final Type returnType, - final boolean isFinal, final boolean isStatic) { - super(); - this.definingType = definingType; - this.name = name; - this.annotations = annotations; - this.comment = comment; - this.accessModifier = accessModifier; - this.returnType = returnType; - this.isFinal = isFinal; - this.isStatic = isStatic; - } - - @Override - public List getAnnotations() { - return annotations; - } - - @Override - public String getName() { - return name; - } - - @Override - public String getComment() { - return comment; - } - - @Override - public Type getDefiningType() { - return definingType; - } - - @Override - public AccessModifier getAccessModifier() { - return accessModifier; - } - - @Override - public Type getReturnType() { - return returnType; - } - - @Override - public boolean isFinal() { - return isFinal; - } - - @Override - public boolean isStatic() { - return isStatic; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + Objects.hashCode(getName()); - result = prime * result + Objects.hashCode(getReturnType()); - return result; - } - - @Override - public boolean equals(final Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - AbstractTypeMember other = (AbstractTypeMember) obj; - return Objects.equals(getName(), other.getName()) && Objects.equals(getReturnType(), other.getReturnType()); - } - - @Override - public String toString() { - StringBuilder builder = new StringBuilder(); - builder.append("MethodSignatureImpl [name="); - builder.append(getName()); - builder.append(", comment="); - builder.append(getComment()); - if (getDefiningType() != null) { - builder.append(", definingType="); - builder.append(getDefiningType().getPackageName()); - builder.append("."); - builder.append(getDefiningType().getName()); - } else { - builder.append(", definingType= null"); - } - builder.append(", returnType="); - builder.append(getReturnType()); - builder.append(", annotations="); - builder.append(getAnnotations()); - builder.append("]"); - return builder.toString(); - } -} diff --git a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/AbstractTypeMemberBuilder.java b/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/AbstractTypeMemberBuilder.java deleted file mode 100644 index 1b54d8ba06..0000000000 --- a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/AbstractTypeMemberBuilder.java +++ /dev/null @@ -1,170 +0,0 @@ -/* - * Copyright (c) 2013 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.yangtools.binding.generator.util.generated.type.builder; - -import com.google.common.base.Preconditions; -import com.google.common.collect.ImmutableList; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Objects; -import org.opendaylight.mdsal.binding.model.api.AccessModifier; -import org.opendaylight.mdsal.binding.model.api.AnnotationType; -import org.opendaylight.mdsal.binding.model.api.Type; -import org.opendaylight.mdsal.binding.model.api.type.builder.AnnotationTypeBuilder; -import org.opendaylight.mdsal.binding.model.api.type.builder.TypeMemberBuilder; -import org.opendaylight.yangtools.util.LazyCollections; - -/** - * @deprecated Use {org.opendaylight.mdsal.binding.generator.util.generated.type.builder.AbstractTypeMemberBuilder} instead. - */ -@Deprecated -abstract class AbstractTypeMemberBuilder> implements TypeMemberBuilder { - private final String name; - private Type returnType; - private List annotationBuilders = Collections.emptyList(); - private String comment = ""; - private boolean isFinal; - private boolean isStatic; - private AccessModifier accessModifier; - - public AbstractTypeMemberBuilder(final String name) { - this.name = name; - } - - @Override - public AnnotationTypeBuilder addAnnotation(final String packageName, final String name) { - Preconditions.checkArgument(packageName != null, "Annotation Type cannot have package name null!"); - Preconditions.checkArgument(name != null, "Annotation Type cannot have name as null!"); - - final AnnotationTypeBuilder builder = new AnnotationTypeBuilderImpl(packageName, name); - annotationBuilders = LazyCollections.lazyAdd(annotationBuilders, builder); - return builder; - } - - protected Type getReturnType() { - return returnType; - } - - protected Iterable getAnnotationBuilders() { - return annotationBuilders; - } - - protected String getComment() { - return comment; - } - - protected boolean isFinal() { - return isFinal; - } - - protected boolean isStatic() { - return isStatic; - } - - @Override - public AccessModifier getAccessModifier() { - return accessModifier; - } - - @Override - public String getName() { - return name; - } - - protected abstract T thisInstance(); - - @Override - public T setReturnType(final Type returnType) { - Preconditions.checkArgument(returnType != null, "Return Type of member cannot be null!"); - this.returnType = returnType; - return thisInstance(); - } - - @Override - public T setAccessModifier(final AccessModifier modifier) { - Preconditions.checkArgument(modifier != null, "Access Modifier for member type cannot be null!"); - this.accessModifier = modifier; - return thisInstance(); - } - - @Override - public T setComment(final String comment) { - if (comment == null) { - this.comment = ""; - } - this.comment = comment; - return thisInstance(); - } - - @Override - public T setFinal(final boolean isFinal) { - this.isFinal = isFinal; - return thisInstance(); - } - - @Override - public T setStatic(final boolean isStatic) { - this.isStatic = isStatic; - return thisInstance(); - } - - protected List toAnnotationTypes() { - final List annotations = new ArrayList<>(); - for (final AnnotationTypeBuilder annotBuilder : getAnnotationBuilders()) { - if (annotBuilder != null) { - annotations.add(annotBuilder.toInstance()); - } - } - - return ImmutableList.copyOf(annotations); - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + Objects.hashCode(getName()); - result = prime * result + Objects.hashCode(getReturnType()); - return result; - } - - @Override - public boolean equals(final Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - AbstractTypeMemberBuilder other = (AbstractTypeMemberBuilder) obj; - return Objects.equals(getName(), other.getName()) && Objects.equals(getReturnType(), other.getReturnType()); - } - - @Override - public String toString() { - StringBuilder builder = new StringBuilder(); - builder.append("GeneratedPropertyImpl [name="); - builder.append(getName()); - builder.append(", annotations="); - builder.append(getAnnotationBuilders()); - builder.append(", comment="); - builder.append(getComment()); - builder.append(", returnType="); - builder.append(getReturnType()); - builder.append(", isFinal="); - builder.append(isFinal()); - builder.append(", modifier="); - builder.append(getAccessModifier()); - builder.append("]"); - return builder.toString(); - } -} diff --git a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/AnnotationTypeBuilderImpl.java b/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/AnnotationTypeBuilderImpl.java deleted file mode 100644 index 2917a8e219..0000000000 --- a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/AnnotationTypeBuilderImpl.java +++ /dev/null @@ -1,309 +0,0 @@ -/* - * Copyright (c) 2013 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.yangtools.binding.generator.util.generated.type.builder; - -import com.google.common.collect.ImmutableList; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Objects; -import org.opendaylight.mdsal.binding.model.api.AnnotationType; -import org.opendaylight.mdsal.binding.model.api.type.builder.AnnotationTypeBuilder; -import org.opendaylight.yangtools.binding.generator.util.AbstractBaseType; -import org.opendaylight.yangtools.util.LazyCollections; - -/** - * @deprecated Use {@link org.opendaylight.mdsal.binding.generator.util.generated.type.builder.AnnotationTypeBuilderImpl} instead. - */ -@Deprecated -final class AnnotationTypeBuilderImpl extends AbstractBaseType implements AnnotationTypeBuilder { - - private final String packageName; - private final String name; - private List annotationBuilders = Collections.emptyList(); - private List parameters = Collections.emptyList(); - - public AnnotationTypeBuilderImpl(final String packageName, final String name) { - super(packageName, name); - this.packageName = packageName; - this.name = name; - } - - @Override - public AnnotationTypeBuilder addAnnotation(final String packageName, final String name) { - if (packageName != null && name != null) { - final AnnotationTypeBuilder builder = new AnnotationTypeBuilderImpl(packageName, name); - if (!annotationBuilders.contains(builder)) { - annotationBuilders = LazyCollections.lazyAdd(annotationBuilders, builder); - return builder; - } - } - return null; - } - - private boolean addParameter(final ParameterImpl param) { - if (!parameters.contains(param)) { - parameters = LazyCollections.lazyAdd(parameters, param); - return true; - } else { - return false; - } - } - - @Override - public boolean addParameter(final String paramName, final String value) { - if (paramName != null && value != null) { - final ParameterImpl param = new ParameterImpl(paramName, value); - return addParameter(param); - } - return false; - } - - @Override - public boolean addParameters(final String paramName, final List values) { - if (paramName != null && values != null) { - final ParameterImpl param = new ParameterImpl(paramName, values); - return addParameter(param); - } - return false; - } - - @Override - public AnnotationType toInstance() { - return new AnnotationTypeImpl(packageName, name, annotationBuilders, parameters); - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + Objects.hashCode(name); - result = prime * result + Objects.hashCode(packageName); - return result; - } - - @Override - public boolean equals(final Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - AnnotationTypeBuilderImpl other = (AnnotationTypeBuilderImpl) obj; - return Objects.equals(name, other.name) && Objects.equals(packageName, other.packageName); - } - - @Override - public String toString() { - StringBuilder builder = new StringBuilder(); - builder.append("AnnotationTypeBuilder [packageName="); - builder.append(packageName); - builder.append(", name="); - builder.append(name); - builder.append(", annotationBuilders="); - builder.append(annotationBuilders); - builder.append(", parameters="); - builder.append(parameters); - builder.append("]"); - return builder.toString(); - } - - private static final class AnnotationTypeImpl implements AnnotationType { - - private final String packageName; - private final String name; - private final List annotations; - private final List parameters; - private final List paramNames; - - public AnnotationTypeImpl(final String packageName, final String name, - final List annotationBuilders, - final List parameters) { - super(); - this.packageName = packageName; - this.name = name; - - final List a = new ArrayList<>(); - for (final AnnotationTypeBuilder builder : annotationBuilders) { - a.add(builder.toInstance()); - } - this.annotations = ImmutableList.copyOf(a); - - final List p = new ArrayList<>(); - for (final AnnotationType.Parameter parameter : parameters) { - p.add(parameter.getName()); - } - this.paramNames = ImmutableList.copyOf(p); - - this.parameters = parameters.isEmpty() ? Collections.emptyList() - : Collections.unmodifiableList(parameters); - } - - @Override - public String getPackageName() { - return packageName; - } - - @Override - public String getName() { - return name; - } - - @Override - public String getFullyQualifiedName() { - return packageName + "." + name; - } - - @Override - public List getAnnotations() { - return annotations; - } - - @Override - public Parameter getParameter(final String paramName) { - if (paramName != null) { - for (final AnnotationType.Parameter parameter : parameters) { - if (parameter.getName().equals(paramName)) { - return parameter; - } - } - } - return null; - } - - @Override - public List getParameters() { - return parameters; - } - - @Override - public List getParameterNames() { - return paramNames; - } - - @Override - public boolean containsParameters() { - return !parameters.isEmpty(); - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + Objects.hashCode(name); - result = prime * result + Objects.hashCode(packageName); - return result; - } - - @Override - public boolean equals(final Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - AnnotationTypeImpl other = (AnnotationTypeImpl) obj; - return Objects.equals(name, other.name) && Objects.equals(packageName, other.packageName); - } - - @Override - public String toString() { - StringBuilder builder = new StringBuilder(); - builder.append("AnnotationType [packageName="); - builder.append(packageName); - builder.append(", name="); - builder.append(name); - builder.append(", annotations="); - builder.append(annotations); - builder.append(", parameters="); - builder.append(parameters); - builder.append("]"); - return builder.toString(); - } - } - - private static final class ParameterImpl implements AnnotationType.Parameter { - - private final String name; - private final String value; - private final List values; - - public ParameterImpl(final String name, final String value) { - super(); - this.name = name; - this.value = value; - this.values = Collections.emptyList(); - } - - public ParameterImpl(final String name, final List values) { - super(); - this.name = name; - this.values = values; - this.value = null; - } - - @Override - public String getName() { - return name; - } - - @Override - public String getValue() { - return value; - } - - @Override - public List getValues() { - return values; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + Objects.hashCode(name); - return result; - } - - @Override - public boolean equals(final Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - ParameterImpl other = (ParameterImpl) obj; - return Objects.equals(name, other.name); - } - - @Override - public String toString() { - StringBuilder builder = new StringBuilder(); - builder.append("ParameterImpl [name="); - builder.append(name); - builder.append(", value="); - builder.append(value); - builder.append(", values="); - builder.append(values); - builder.append("]"); - return builder.toString(); - } - } -} diff --git a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/ConstantImpl.java b/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/ConstantImpl.java deleted file mode 100644 index 7d4a8cd775..0000000000 --- a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/ConstantImpl.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright (c) 2013 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.yangtools.binding.generator.util.generated.type.builder; - -import java.util.Objects; -import org.opendaylight.mdsal.binding.model.api.Constant; -import org.opendaylight.mdsal.binding.model.api.Type; - -/** - * @deprecated Use {@link org.opendaylight.mdsal.binding.generator.util.generated.type.builder.ConstantImpl} instead. - */ -@Deprecated -final class ConstantImpl implements Constant { - - private final Type definingType; - private final Type type; - private final String name; - private final Object value; - - public ConstantImpl(final Type definingType, final Type type, final String name, final Object value) { - super(); - this.definingType = definingType; - this.type = type; - this.name = name; - this.value = value; - } - - @Override - public Type getDefiningType() { - return definingType; - } - - @Override - public Type getType() { - return type; - } - - @Override - public String getName() { - return name; - } - - @Override - public Object getValue() { - return value; - } - - @Override - public String toFormattedString() { - StringBuilder builder = new StringBuilder(); - builder.append(type); - builder.append(" "); - builder.append(name); - builder.append(" "); - builder.append(value); - return builder.toString(); - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + Objects.hashCode(name); - result = prime * result + Objects.hashCode(type); - return result; - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(final Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - ConstantImpl other = (ConstantImpl) obj; - return Objects.equals(name, other.name) && Objects.equals(type, other.type) && Objects.equals(value, other.value); - } - - @Override - public String toString() { - StringBuilder builder = new StringBuilder(); - builder.append("Constant [type="); - builder.append(type); - builder.append(", name="); - builder.append(name); - builder.append(", value="); - builder.append(value); - if (definingType != null) { - builder.append(", definingType="); - builder.append(definingType.getPackageName()); - builder.append("."); - builder.append(definingType.getName()); - } else { - builder.append(", definingType= null"); - } - builder.append("]"); - return builder.toString(); - } -} diff --git a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/EnumerationBuilderImpl.java b/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/EnumerationBuilderImpl.java deleted file mode 100644 index 6fb8249176..0000000000 --- a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/EnumerationBuilderImpl.java +++ /dev/null @@ -1,385 +0,0 @@ -/* - * Copyright (c) 2013 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.yangtools.binding.generator.util.generated.type.builder; - -import com.google.common.collect.ImmutableList; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Objects; -import org.opendaylight.mdsal.binding.model.api.AnnotationType; -import org.opendaylight.mdsal.binding.model.api.Constant; -import org.opendaylight.mdsal.binding.model.api.Enumeration; -import org.opendaylight.mdsal.binding.model.api.GeneratedProperty; -import org.opendaylight.mdsal.binding.model.api.GeneratedType; -import org.opendaylight.mdsal.binding.model.api.MethodSignature; -import org.opendaylight.mdsal.binding.model.api.Type; -import org.opendaylight.mdsal.binding.model.api.Enumeration.Pair; -import org.opendaylight.mdsal.binding.model.api.type.builder.AnnotationTypeBuilder; -import org.opendaylight.mdsal.binding.model.api.type.builder.EnumBuilder; -import org.opendaylight.yangtools.binding.generator.util.AbstractBaseType; -import org.opendaylight.yangtools.util.LazyCollections; -import org.opendaylight.yangtools.yang.binding.BindingMapping; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.model.api.Status; -import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition; -import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition.EnumPair; - -/** - * @deprecated Use {@link org.opendaylight.mdsal.binding.generator.util.generated.type.builder.EnumerationBuilderImpl} instead. - */ -@Deprecated -public final class EnumerationBuilderImpl extends AbstractBaseType implements EnumBuilder { - private final String packageName; - private final String name; - private List values = Collections.emptyList(); - private List annotationBuilders = Collections.emptyList(); - private List unmodifiableValues = Collections.emptyList(); - private String description; - private String reference; - private String moduleName; - private Iterable schemaPath; - - public EnumerationBuilderImpl(final String packageName, final String name) { - super(packageName, name); - this.packageName = packageName; - this.name = name; - } - - public void setReference(final String reference) { - this.reference = reference; - } - - public void setModuleName(final String moduleName) { - this.moduleName = moduleName; - } - - public void setSchemaPath(final Iterable schemaPath) { - this.schemaPath = schemaPath; - } - - @Override - public void setDescription(final String description) { - this.description = description; - - } - - @Override - public AnnotationTypeBuilder addAnnotation(final String packageName, final String name) { - if (packageName != null && name != null) { - final AnnotationTypeBuilder builder = new AnnotationTypeBuilderImpl(packageName, name); - if (!annotationBuilders.contains(builder)) { - annotationBuilders = LazyCollections.lazyAdd(annotationBuilders, builder); - return builder; - } - } - return null; - } - - @Override - public void addValue(final String name, final int value, final String description) { - final EnumPairImpl p = new EnumPairImpl(name, value, description); - values = LazyCollections.lazyAdd(values, p); - unmodifiableValues = Collections.unmodifiableList(values); - } - - @Override - public Enumeration toInstance(final Type definingType) { - return new EnumerationImpl(definingType, annotationBuilders, packageName, name, unmodifiableValues, - description, reference, moduleName, schemaPath); - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - StringBuilder builder = new StringBuilder(); - builder.append("EnumerationBuilderImpl [packageName="); - builder.append(packageName); - builder.append(", name="); - builder.append(name); - builder.append(", values="); - builder.append(values); - builder.append("]"); - return builder.toString(); - } - - @Override - public void updateEnumPairsFromEnumTypeDef(final EnumTypeDefinition enumTypeDef) { - final List enums = enumTypeDef.getValues(); - if (enums != null) { - for (final EnumPair enumPair : enums) { - if (enumPair != null) { - this.addValue(enumPair.getName(), enumPair.getValue(), enumPair.getDescription()); - } - } - } - - } - - private static final class EnumPairImpl implements Enumeration.Pair { - - private final String name; - private final String mappedName; - private final int value; - private final String description; - - public EnumPairImpl(final String name, final int value, final String description) { - super(); - this.name = name; - this.mappedName = BindingMapping.getClassName(name); - this.value = value; - this.description = description; - } - - @Override - public String getName() { - return name; - } - - @Override - public String getMappedName() { - return mappedName; - } - - @Override - public int getValue() { - return value; - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + Objects.hashCode(name); - result = prime * result + Objects.hashCode(value); - return result; - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(final Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - EnumPairImpl other = (EnumPairImpl) obj; - return Objects.equals(name, other.name) && Objects.equals(value, other.value); - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - StringBuilder builder = new StringBuilder(); - builder.append("EnumPair [name="); - builder.append(name); - builder.append(", mappedName="); - builder.append(getMappedName()); - builder.append(", value="); - builder.append(value); - builder.append("]"); - return builder.toString(); - } - - @Override - public String getDescription() { - return description; - } - - @Override - public String getReference() { - return null; - } - - @Override - public Status getStatus() { - // TODO Auto-generated method stub - return null; - } - - } - - private static final class EnumerationImpl extends AbstractBaseType implements Enumeration { - - private final Type definingType; - private final String description; - private final String reference; - private final String moduleName; - private final Iterable schemaPath; - private final List values; - private final List annotations; - - public EnumerationImpl(final Type definingType, final List annotationBuilders, - final String packageName, final String name, final List values, final String description, - final String reference, final String moduleName, final Iterable schemaPath) { - super(packageName, name); - this.definingType = definingType; - this.values = values; - this.description = description; - this.moduleName = moduleName; - this.schemaPath = schemaPath; - this.reference = reference; - - final ArrayList a = new ArrayList<>(); - for (final AnnotationTypeBuilder builder : annotationBuilders) { - a.add(builder.toInstance()); - } - this.annotations = ImmutableList.copyOf(a); - } - - @Override - public Type getParentType() { - return definingType; - } - - @Override - public List getValues() { - return values; - } - - @Override - public List getAnnotations() { - return annotations; - } - - @Override - public String toFormattedString() { - StringBuilder builder = new StringBuilder(); - builder.append("public enum"); - builder.append(" "); - builder.append(getName()); - builder.append(" {"); - builder.append("\n"); - - int i = 0; - for (final Enumeration.Pair valPair : values) { - builder.append("\t"); - builder.append(" "); - builder.append(valPair.getMappedName()); - builder.append(" ("); - builder.append(valPair.getValue()); - - if (i == (values.size() - 1)) { - builder.append(" );"); - } else { - builder.append(" ),"); - } - ++i; - } - builder.append("\n}"); - return builder.toString(); - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - StringBuilder builder = new StringBuilder(); - builder.append("Enumeration [packageName="); - builder.append(getPackageName()); - if (definingType != null) { - builder.append(", definingType="); - builder.append(definingType.getPackageName()); - builder.append("."); - builder.append(definingType.getName()); - } else { - builder.append(", definingType= null"); - } - builder.append(", name="); - builder.append(getName()); - builder.append(", values="); - builder.append(values); - builder.append("]"); - return builder.toString(); - } - - @Override - public String getComment() { - return null; - } - - @Override - public boolean isAbstract() { - return false; - } - - @Override - public List getImplements() { - return Collections.emptyList(); - } - - @Override - public List getEnclosedTypes() { - return Collections.emptyList(); - } - - @Override - public List getEnumerations() { - return Collections.emptyList(); - } - - @Override - public List getConstantDefinitions() { - return Collections.emptyList(); - } - - @Override - public List getMethodDefinitions() { - return Collections.emptyList(); - } - - @Override - public List getProperties() { - return Collections.emptyList(); - } - - @Override - public String getDescription() { - return description; - } - - @Override - public String getReference() { - return reference; - } - - @Override - public Iterable getSchemaPath() { - return schemaPath; - } - - @Override - public String getModuleName() { - return moduleName; - } - } -} diff --git a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/GeneratedPropertyBuilderImpl.java b/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/GeneratedPropertyBuilderImpl.java deleted file mode 100644 index 4a32ea8be7..0000000000 --- a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/GeneratedPropertyBuilderImpl.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2013 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.yangtools.binding.generator.util.generated.type.builder; - -import java.util.List; -import org.opendaylight.mdsal.binding.model.api.AnnotationType; -import org.opendaylight.mdsal.binding.model.api.GeneratedProperty; -import org.opendaylight.mdsal.binding.model.api.Type; -import org.opendaylight.mdsal.binding.model.api.type.builder.GeneratedPropertyBuilder; - -/** - * @deprecated Use {@link org.opendaylight.mdsal.binding.generator.util.generated.type.builder.GeneratedPropertyBuilderImpl} instead. - */ -@Deprecated -public final class GeneratedPropertyBuilderImpl extends AbstractTypeMemberBuilder implements GeneratedPropertyBuilder { - private String value; - private boolean isReadOnly; - - public GeneratedPropertyBuilderImpl(String name) { - super(name); - this.isReadOnly = true; - } - - @Override - public GeneratedPropertyBuilderImpl setValue(String value) { - this.value = value; - return this; - } - - @Override - public GeneratedPropertyBuilderImpl setReadOnly(boolean isReadOnly) { - this.isReadOnly = isReadOnly; - return this; - } - - @Override - protected GeneratedPropertyBuilderImpl thisInstance() { - return this; - } - - @Override - public GeneratedProperty toInstance(Type definingType) { - final List annotations = toAnnotationTypes(); - return new GeneratedPropertyImpl(definingType, getName(), annotations, getComment(), getAccessModifier(), - getReturnType(), isFinal(), isStatic(), isReadOnly, value); - } - - @Override - public String toString() { - StringBuilder builder = new StringBuilder(); - builder.append("GeneratedPropertyImpl [name="); - builder.append(getName()); - builder.append(", annotations="); - builder.append(getAnnotationBuilders()); - builder.append(", comment="); - builder.append(getComment()); - builder.append(", returnType="); - builder.append(getReturnType()); - builder.append(", isFinal="); - builder.append(isFinal()); - builder.append(", isReadOnly="); - builder.append(isReadOnly); - builder.append(", modifier="); - builder.append(getAccessModifier()); - builder.append("]"); - return builder.toString(); - } -} \ No newline at end of file diff --git a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/GeneratedPropertyImpl.java b/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/GeneratedPropertyImpl.java deleted file mode 100644 index 0c21a04384..0000000000 --- a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/GeneratedPropertyImpl.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2013 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.yangtools.binding.generator.util.generated.type.builder; - -import java.util.List; -import org.opendaylight.mdsal.binding.model.api.AccessModifier; -import org.opendaylight.mdsal.binding.model.api.AnnotationType; -import org.opendaylight.mdsal.binding.model.api.GeneratedProperty; -import org.opendaylight.mdsal.binding.model.api.Type; - -/** - * @deprecated Use {@link org.opendaylight.mdsal.binding.generator.util.generated.type.builder.GeneratedPropertyImpl} instead. - */ -@Deprecated -final class GeneratedPropertyImpl extends AbstractTypeMember implements GeneratedProperty { - private String value; - private boolean isReadOnly; - - public GeneratedPropertyImpl(Type definingType, String name, List annotations, String comment, - AccessModifier accessModifier, Type returnType, boolean isFinal, boolean isStatic, boolean isReadOnly, String value) { - super(definingType, name, annotations, comment, accessModifier, returnType, isFinal, isStatic); - this.value = value; - this.isReadOnly = isReadOnly; - } - - @Override - public String getValue() { - return value; - } - - @Override - public boolean isReadOnly() { - return isReadOnly; - } - - @Override - public String toString() { - StringBuilder builder = new StringBuilder(); - builder.append("GeneratedPropertyImpl [name="); - builder.append(getName()); - builder.append(", annotations="); - builder.append(getAnnotations()); - builder.append(", comment="); - builder.append(getComment()); - if (getDefiningType() != null) { - builder.append(", parent="); - builder.append(getDefiningType().getPackageName()); - builder.append("."); - builder.append(getDefiningType().getName()); - } else { - builder.append(", parent=null"); - } - builder.append(", returnType="); - builder.append(getReturnType()); - builder.append(", isFinal="); - builder.append(isFinal()); - builder.append(", isReadOnly="); - builder.append(isReadOnly); - builder.append(", modifier="); - builder.append(getAccessModifier()); - builder.append("]"); - return builder.toString(); - } -} diff --git a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/GeneratedTOBuilderImpl.java b/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/GeneratedTOBuilderImpl.java deleted file mode 100644 index c289ae2bf1..0000000000 --- a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/GeneratedTOBuilderImpl.java +++ /dev/null @@ -1,359 +0,0 @@ -/* - * Copyright (c) 2013 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.yangtools.binding.generator.util.generated.type.builder; - -import com.google.common.base.Preconditions; -import java.util.Collections; -import java.util.List; -import org.opendaylight.mdsal.binding.model.api.GeneratedProperty; -import org.opendaylight.mdsal.binding.model.api.GeneratedTransferObject; -import org.opendaylight.mdsal.binding.model.api.ParameterizedType; -import org.opendaylight.mdsal.binding.model.api.Restrictions; -import org.opendaylight.mdsal.binding.model.api.Type; -import org.opendaylight.mdsal.binding.model.api.type.builder.GeneratedPropertyBuilder; -import org.opendaylight.mdsal.binding.model.api.type.builder.GeneratedTOBuilder; -import org.opendaylight.mdsal.binding.model.api.type.builder.MethodSignatureBuilder; -import org.opendaylight.yangtools.util.LazyCollections; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.model.api.TypeDefinition; - -/** - * @deprecated Use {@link org.opendaylight.mdsal.binding.generator.util.generated.type.builder.GeneratedTOBuilderImpl} instead. - */ -@Deprecated -public final class GeneratedTOBuilderImpl extends AbstractGeneratedTypeBuilder implements GeneratedTOBuilder { - - private GeneratedTransferObject extendsType; - private List equalsProperties = Collections.emptyList(); - private List hashProperties = Collections.emptyList(); - private List toStringProperties = Collections.emptyList(); - private boolean isTypedef = false; - private boolean isUnionType = false; - private boolean isUnionTypeBuilder = false; - private TypeDefinition baseType = null; - private Restrictions restrictions; - private GeneratedPropertyBuilder SUID; - private String reference; - private String description; - private String moduleName; - private Iterable schemaPath; - - public GeneratedTOBuilderImpl(final String packageName, final String name) { - super(packageName, name); - setAbstract(false); - } - - @Override - public GeneratedTOBuilder setExtendsType(final GeneratedTransferObject genTransObj) { - Preconditions.checkArgument(genTransObj != null, "Generated Transfer Object cannot be null!"); - extendsType = genTransObj; - return this; - } - - /** - * Add new Method Signature definition for Generated Type Builder and - * returns Method Signature Builder for specifying all Method parameters.
- * Name of Method cannot be null, if it is null - * the method SHOULD throw {@link IllegalArgumentException}
- * By Default the MethodSignatureBuilder SHOULD be pre-set as - * {@link MethodSignatureBuilder#setAbstract(boolean)}, - * {TypeMemberBuilder#setFinal(boolean)} and - * {TypeMemberBuilder#setAccessModifier(boolean)} - * - * @param name - * Name of Method - * @return new instance of Method Signature Builder. - */ - @Override - public MethodSignatureBuilder addMethod(final String name) { - final MethodSignatureBuilder builder = super.addMethod(name); - builder.setAbstract(false); - return builder; - } - - @Override - public GeneratedTOBuilder addEqualsIdentity(final GeneratedPropertyBuilder property) { - equalsProperties = LazyCollections.lazyAdd(equalsProperties, property); - return this; - } - - @Override - public GeneratedTOBuilder addHashIdentity(final GeneratedPropertyBuilder property) { - hashProperties = LazyCollections.lazyAdd(hashProperties, property); - return this; - } - - @Override - public GeneratedTOBuilder addToStringProperty(final GeneratedPropertyBuilder property) { - toStringProperties = LazyCollections.lazyAdd(toStringProperties, property); - return this; - } - - @Override - protected GeneratedTOBuilder thisInstance() { - return this; - } - - @Override - public void setRestrictions(final Restrictions restrictions) { - this.restrictions = restrictions; - } - - @Override - public void setSUID(final GeneratedPropertyBuilder suid) { - this.SUID = suid; - } - - @Override - public GeneratedTransferObject toInstance() { - return new GeneratedTransferObjectImpl(this); - } - - @Override - public String toString() { - StringBuilder builder = new StringBuilder(); - builder.append("GeneratedTransferObject [packageName="); - builder.append(getPackageName()); - builder.append(", name="); - builder.append(getName()); - builder.append(", comment="); - builder.append(getComment()); - builder.append(", constants="); - builder.append(getConstants()); - builder.append(", enumerations="); - builder.append(getEnumerations()); - builder.append(", equalsProperties="); - builder.append(equalsProperties); - builder.append(", hashCodeProperties="); - builder.append(hashProperties); - builder.append(", stringProperties="); - builder.append(toStringProperties); - builder.append(", annotations="); - builder.append(getAnnotations()); - builder.append(", methods="); - builder.append(getMethodDefinitions()); - builder.append("]"); - return builder.toString(); - } - - @Override - public void setTypedef(final boolean isTypedef) { - this.isTypedef = isTypedef; - } - - @Override - public void setBaseType(final TypeDefinition typeDef) { - this.baseType = typeDef; - } - - @Override - public void setIsUnion(final boolean isUnion) { - this.isUnionType = isUnion; - } - - @Override - public void setIsUnionBuilder(final boolean isUnionTypeBuilder) { - this.isUnionTypeBuilder = isUnionTypeBuilder; - } - - @Override - public void setDescription(String description) { - this.description = description; - } - - @Override - public void setModuleName(String moduleName) { - this.moduleName = moduleName; - } - - @Override - public void setSchemaPath(Iterable schemaPath) { - this.schemaPath = schemaPath; - } - - @Override - public void setReference(String reference) { - this.reference = reference; - } - - private static final class GeneratedTransferObjectImpl extends AbstractGeneratedType implements - GeneratedTransferObject { - - private final List equalsProperties; - private final List hashCodeProperties; - private final List stringProperties; - private final GeneratedTransferObject extendsType; - private final boolean isTypedef; - private final TypeDefinition baseType; - private final boolean isUnionType; - private final boolean isUnionTypeBuilder; - private final Restrictions restrictions; - private final GeneratedProperty SUID; - private final String reference; - private final String description; - private final String moduleName; - private final Iterable schemaPath; - - public GeneratedTransferObjectImpl(final GeneratedTOBuilderImpl builder) { - super(builder); - this.extendsType = builder.extendsType; - - // FIXME: if these fields were guaranteed to be constant, we could perhaps - // cache and reuse them between instances... - this.equalsProperties = toUnmodifiableProperties(builder.equalsProperties); - this.hashCodeProperties = toUnmodifiableProperties(builder.hashProperties); - this.stringProperties = toUnmodifiableProperties(builder.toStringProperties); - - this.isTypedef = builder.isTypedef; - this.baseType = builder.baseType; - this.isUnionType = builder.isUnionType; - this.isUnionTypeBuilder = builder.isUnionTypeBuilder; - this.restrictions = builder.restrictions; - this.reference = builder.reference; - this.description = builder.description; - this.moduleName = builder.moduleName; - this.schemaPath = builder.schemaPath; - - if (builder.SUID == null) { - this.SUID = null; - } else { - this.SUID = builder.SUID.toInstance(GeneratedTransferObjectImpl.this); - } - } - - @Override - public boolean isTypedef() { - return isTypedef; - } - - @Override - public TypeDefinition getBaseType() { - return baseType; - } - - @Override - public boolean isUnionType() { - return isUnionType; - } - - @Override - public boolean isUnionTypeBuilder() { - return isUnionTypeBuilder; - } - - @Override - public GeneratedTransferObject getSuperType() { - return extendsType; - } - - @Override - public List getEqualsIdentifiers() { - return equalsProperties; - } - - @Override - public List getHashCodeIdentifiers() { - return hashCodeProperties; - } - - @Override - public List getToStringIdentifiers() { - return stringProperties; - } - - @Override - public Restrictions getRestrictions() { - return restrictions; - } - - @Override - public GeneratedProperty getSUID() { - return SUID; - } - - @Override - public String toString() { - if (isTypedef) { - return serializeTypedef(this); - } - StringBuilder builder = new StringBuilder(); - builder.append("GeneratedTransferObject [packageName="); - builder.append(getPackageName()); - builder.append(", name="); - builder.append(getName()); - builder.append(", comment="); - builder.append(", annotations="); - builder.append(getAnnotations()); - builder.append(getComment()); - builder.append(", extends="); - builder.append(getSuperType()); - builder.append(", implements="); - builder.append(getImplements()); - builder.append(", enclosedTypes="); - builder.append(getEnclosedTypes()); - builder.append(", constants="); - builder.append(getConstantDefinitions()); - builder.append(", enumerations="); - builder.append(getEnumerations()); - builder.append(", properties="); - builder.append(getProperties()); - builder.append(", equalsProperties="); - builder.append(equalsProperties); - builder.append(", hashCodeProperties="); - builder.append(hashCodeProperties); - builder.append(", stringProperties="); - builder.append(stringProperties); - builder.append(", methods="); - builder.append(getMethodDefinitions()); - builder.append("]"); - return builder.toString(); - } - - public String serializeTypedef(final Type type) { - if (type instanceof ParameterizedType) { - ParameterizedType parameterizedType = (ParameterizedType) type; - StringBuilder sb = new StringBuilder(); - sb.append(parameterizedType.getRawType().getFullyQualifiedName()); - sb.append('<'); - boolean first = true; - for (Type parameter : parameterizedType.getActualTypeArguments()) { - if (first) { - first = false; - } else { - sb.append(','); - } - sb.append(serializeTypedef(parameter)); - } - sb.append('>'); - return sb.toString(); - } else { - return type.getFullyQualifiedName(); - } - } - - @Override - public String getDescription() { - return description; - } - - @Override - public String getReference() { - return reference; - } - - @Override - public Iterable getSchemaPath() { - return schemaPath; - } - - @Override - public String getModuleName() { - return moduleName; - } - } -} diff --git a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/GeneratedTypeBuilderImpl.java b/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/GeneratedTypeBuilderImpl.java deleted file mode 100644 index 2f4a8db52d..0000000000 --- a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/GeneratedTypeBuilderImpl.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright (c) 2013 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.yangtools.binding.generator.util.generated.type.builder; - -import org.opendaylight.mdsal.binding.model.api.GeneratedType; -import org.opendaylight.mdsal.binding.model.api.type.builder.GeneratedTypeBuilder; -import org.opendaylight.yangtools.yang.common.QName; - -/** - * @deprecated Use {@link org.opendaylight.mdsal.binding.generator.util.generated.type.builder.GeneratedTypeBuilderImpl} instead. - */ -@Deprecated -public final class GeneratedTypeBuilderImpl extends AbstractGeneratedTypeBuilder implements - GeneratedTypeBuilder { - - private String description; - private String reference; - private String moduleName; - private Iterable schemaPath; - - public GeneratedTypeBuilderImpl(final String packageName, final String name) { - super(packageName, name); - setAbstract(true); - } - - @Override - public GeneratedType toInstance() { - return new GeneratedTypeImpl(this); - } - - @Override - public void setDescription(String description) { - this.description = description; - } - - @Override - public void setModuleName(String moduleName) { - this.moduleName = moduleName; - } - - @Override - public void setSchemaPath(Iterable schemaPath) { - this.schemaPath = schemaPath; - } - - @Override - public void setReference(String reference) { - this.reference = reference; - } - - @Override - public String toString() { - StringBuilder builder = new StringBuilder(); - builder.append("GeneratedTransferObject [packageName="); - builder.append(getPackageName()); - builder.append(", name="); - builder.append(getName()); - builder.append(", comment="); - builder.append(getComment()); - builder.append(", annotations="); - builder.append(getAnnotations()); - builder.append(", implements="); - builder.append(getImplementsTypes()); - builder.append(", enclosedTypes="); - builder.append(getEnclosedTypes()); - builder.append(", constants="); - builder.append(getConstants()); - builder.append(", enumerations="); - builder.append(getEnumerations()); - builder.append(", properties="); - builder.append(", methods="); - builder.append(getMethodDefinitions()); - builder.append("]"); - return builder.toString(); - } - - @Override - protected GeneratedTypeBuilderImpl thisInstance() { - return this; - } - - private static final class GeneratedTypeImpl extends AbstractGeneratedType { - - private final String description; - private final String reference; - private final String moduleName; - private final Iterable schemaPath; - - public GeneratedTypeImpl(GeneratedTypeBuilderImpl builder) { - super(builder); - - this.description = builder.description; - this.reference = builder.reference; - this.moduleName = builder.moduleName; - this.schemaPath = builder.schemaPath; - } - - @Override - public String getDescription() { - return description; - } - - @Override - public String getReference() { - return reference; - } - - @Override - public Iterable getSchemaPath() { - return schemaPath; - } - - @Override - public String getModuleName() { - return moduleName; - } - } -} diff --git a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/MethodParameterImpl.java b/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/MethodParameterImpl.java deleted file mode 100644 index f70a1e72b2..0000000000 --- a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/MethodParameterImpl.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (c) 2013 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.yangtools.binding.generator.util.generated.type.builder; - -import java.util.Objects; -import org.opendaylight.mdsal.binding.model.api.Type; -import org.opendaylight.mdsal.binding.model.api.MethodSignature.Parameter; - -/** - * @deprecated Use {@link org.opendaylight.mdsal.binding.generator.util.generated.type.builder.MethodParameterImpl} instead. - */ -@Deprecated -final class MethodParameterImpl implements Parameter { - - private final String name; - private final Type type; - - public MethodParameterImpl(final String name, final Type type) { - super(); - this.name = name; - this.type = type; - } - - @Override - public String getName() { - return name; - } - - @Override - public Type getType() { - return type; - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + Objects.hashCode(name); - result = prime * result + Objects.hashCode(type); - return result; - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(final Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - MethodParameterImpl other = (MethodParameterImpl) obj; - return Objects.equals(name, other.name) && Objects.equals(type, other.type); - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - StringBuilder builder = new StringBuilder(); - builder.append("MethodParameter [name="); - builder.append(name); - builder.append(", type="); - builder.append(type.getPackageName()); - builder.append("."); - builder.append(type.getName()); - builder.append("]"); - return builder.toString(); - } -} diff --git a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/MethodSignatureBuilderImpl.java b/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/MethodSignatureBuilderImpl.java deleted file mode 100644 index cf5a24830d..0000000000 --- a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/MethodSignatureBuilderImpl.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright (c) 2013 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.yangtools.binding.generator.util.generated.type.builder; - -import java.util.Collections; -import java.util.List; -import java.util.Objects; -import org.opendaylight.mdsal.binding.model.api.AnnotationType; -import org.opendaylight.mdsal.binding.model.api.MethodSignature; -import org.opendaylight.mdsal.binding.model.api.Type; -import org.opendaylight.mdsal.binding.model.api.type.builder.MethodSignatureBuilder; -import org.opendaylight.yangtools.util.LazyCollections; - -/** - * @deprecated Use {@link org.opendaylight.mdsal.binding.generator.util.generated.type.builder.MethodSignatureBuilderImpl} instead. - */ -@Deprecated -final class MethodSignatureBuilderImpl extends AbstractTypeMemberBuilder implements MethodSignatureBuilder { - - private List parameters = Collections.emptyList(); - private List unmodifiableParams = Collections.emptyList(); - private boolean isAbstract; - - public MethodSignatureBuilderImpl(final String name) { - super(name); - } - - @Override - public MethodSignatureBuilder setAbstract(final boolean isAbstract) { - this.isAbstract = isAbstract; - return this; - } - - @Override - public MethodSignatureBuilder addParameter(final Type type, final String name) { - parameters = LazyCollections.lazyAdd(parameters, new MethodParameterImpl(name, type)); - unmodifiableParams = Collections.unmodifiableList(parameters); - return this; - } - - @Override - protected MethodSignatureBuilder thisInstance() { - return this; - } - - @Override - public MethodSignature toInstance(final Type definingType) { - final List annotations = toAnnotationTypes(); - return new MethodSignatureImpl(definingType, getName(), annotations, getComment(), getAccessModifier(), - getReturnType(), unmodifiableParams, isFinal(), isAbstract, isStatic()); - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + Objects.hashCode(getName()); - result = prime * result + Objects.hashCode(parameters); - result = prime * result + Objects.hashCode(getReturnType()); - return result; - } - - @Override - public boolean equals(final Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - MethodSignatureBuilderImpl other = (MethodSignatureBuilderImpl) obj; - if (!Objects.equals(getName(), other.getName())) { - return false; - } - if (!Objects.equals(parameters, other.parameters)) { - return false; - } - if (!Objects.equals(getReturnType(), other.getReturnType())) { - return false; - } - return true; - } - - @Override - public String toString() { - StringBuilder builder = new StringBuilder(); - builder.append("MethodSignatureBuilderImpl [name="); - builder.append(getName()); - builder.append(", returnType="); - builder.append(getReturnType()); - builder.append(", parameters="); - builder.append(parameters); - builder.append(", annotationBuilders="); - builder.append(getAnnotationBuilders()); - builder.append(", comment="); - builder.append(getComment()); - builder.append("]"); - return builder.toString(); - } -} diff --git a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/MethodSignatureImpl.java b/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/MethodSignatureImpl.java deleted file mode 100644 index 5d21010b6b..0000000000 --- a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/MethodSignatureImpl.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (c) 2013 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.yangtools.binding.generator.util.generated.type.builder; - -import java.util.List; -import java.util.Objects; -import org.opendaylight.mdsal.binding.model.api.AccessModifier; -import org.opendaylight.mdsal.binding.model.api.AnnotationType; -import org.opendaylight.mdsal.binding.model.api.MethodSignature; -import org.opendaylight.mdsal.binding.model.api.Type; - -/** - * @deprecated Use {@link org.opendaylight.mdsal.binding.generator.util.generated.type.builder.MethodSignatureImpl} instead. - */ -@Deprecated -class MethodSignatureImpl extends AbstractTypeMember implements MethodSignature { - - private final List params; - private final boolean isAbstract; - - public MethodSignatureImpl(final Type definingType, final String name, - final List annotations, - final String comment, final AccessModifier accessModifier, - final Type returnType, final List params, final boolean isFinal, - final boolean isAbstract, final boolean isStatic) { - super(definingType, name, annotations, comment, accessModifier, returnType, isFinal, isStatic); - this.params = params; - this.isAbstract = isAbstract; - } - - @Override - public boolean isAbstract() { - return isAbstract; - } - - @Override - public List getParameters() { - return params; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + Objects.hashCode(getName()); - result = prime * result + Objects.hashCode(params); - result = prime * result + Objects.hashCode(getReturnType()); - return result; - } - - @Override - public boolean equals(final Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - MethodSignatureImpl other = (MethodSignatureImpl) obj; - if (!Objects.equals(getName(), other.getName())) { - return false; - } - if (!Objects.equals(params, other.params)) { - return false; - } - if (!Objects.equals(getReturnType(), other.getReturnType())) { - return false; - } - return true; - } - - @Override - public String toString() { - StringBuilder builder = new StringBuilder(); - builder.append("MethodSignatureImpl [name="); - builder.append(getName()); - builder.append(", comment="); - builder.append(getComment()); - if (getDefiningType() != null) { - builder.append(", definingType="); - builder.append(getDefiningType().getPackageName()); - builder.append("."); - builder.append(getDefiningType().getName()); - } else { - builder.append(", definingType= null"); - } - builder.append(", returnType="); - builder.append(getReturnType()); - builder.append(", params="); - builder.append(params); - builder.append(", annotations="); - builder.append(getAnnotations()); - builder.append("]"); - return builder.toString(); - } -} diff --git a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/package-info.java b/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/package-info.java deleted file mode 100644 index 2621e2eea4..0000000000 --- a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/* - * Copyright (c) 2013 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.yangtools.binding.generator.util; \ No newline at end of file diff --git a/binding/mdsal-binding-java-api-generator/src/main/java/org/opendaylight/yangtools/sal/java/api/generator/BaseTemplate.xtend b/binding/mdsal-binding-java-api-generator/src/main/java/org/opendaylight/yangtools/sal/java/api/generator/BaseTemplate.xtend index 8f385f08f5..006f94999b 100644 --- a/binding/mdsal-binding-java-api-generator/src/main/java/org/opendaylight/yangtools/sal/java/api/generator/BaseTemplate.xtend +++ b/binding/mdsal-binding-java-api-generator/src/main/java/org/opendaylight/yangtools/sal/java/api/generator/BaseTemplate.xtend @@ -16,7 +16,7 @@ import java.util.List import java.util.Map import java.util.StringTokenizer import java.util.regex.Pattern -import org.opendaylight.yangtools.binding.generator.util.Types +import org.opendaylight.mdsal.binding.generator.util.Types import org.opendaylight.mdsal.binding.model.api.ConcreteType import org.opendaylight.mdsal.binding.model.api.Constant import org.opendaylight.mdsal.binding.model.api.GeneratedProperty diff --git a/binding/mdsal-binding-java-api-generator/src/main/java/org/opendaylight/yangtools/sal/java/api/generator/BuilderTemplate.xtend b/binding/mdsal-binding-java-api-generator/src/main/java/org/opendaylight/yangtools/sal/java/api/generator/BuilderTemplate.xtend index b1d5b40853..a36a23ad94 100644 --- a/binding/mdsal-binding-java-api-generator/src/main/java/org/opendaylight/yangtools/sal/java/api/generator/BuilderTemplate.xtend +++ b/binding/mdsal-binding-java-api-generator/src/main/java/org/opendaylight/yangtools/sal/java/api/generator/BuilderTemplate.xtend @@ -19,16 +19,16 @@ import java.util.List import java.util.Map import java.util.Objects import java.util.Set -import org.opendaylight.yangtools.binding.generator.util.ReferencedTypeImpl -import org.opendaylight.yangtools.binding.generator.util.Types -import org.opendaylight.yangtools.binding.generator.util.generated.type.builder.GeneratedTOBuilderImpl -import org.opendaylight.yangtools.concepts.Builder +import org.opendaylight.mdsal.binding.generator.util.ReferencedTypeImpl +import org.opendaylight.mdsal.binding.generator.util.Types +import org.opendaylight.mdsal.binding.generator.util.generated.type.builder.GeneratedTOBuilderImpl import org.opendaylight.mdsal.binding.model.api.ConcreteType import org.opendaylight.mdsal.binding.model.api.GeneratedProperty import org.opendaylight.mdsal.binding.model.api.GeneratedTransferObject import org.opendaylight.mdsal.binding.model.api.GeneratedType import org.opendaylight.mdsal.binding.model.api.MethodSignature import org.opendaylight.mdsal.binding.model.api.Type +import org.opendaylight.yangtools.concepts.Builder import org.opendaylight.yangtools.yang.binding.Augmentable import org.opendaylight.yangtools.yang.binding.AugmentationHolder import org.opendaylight.yangtools.yang.binding.DataObject diff --git a/binding/mdsal-binding-java-api-generator/src/main/java/org/opendaylight/yangtools/sal/java/api/generator/ClassTemplate.xtend b/binding/mdsal-binding-java-api-generator/src/main/java/org/opendaylight/yangtools/sal/java/api/generator/ClassTemplate.xtend index c40d4a9b43..ff9180e6c4 100644 --- a/binding/mdsal-binding-java-api-generator/src/main/java/org/opendaylight/yangtools/sal/java/api/generator/ClassTemplate.xtend +++ b/binding/mdsal-binding-java-api-generator/src/main/java/org/opendaylight/yangtools/sal/java/api/generator/ClassTemplate.xtend @@ -18,7 +18,7 @@ import java.util.Collections import java.util.List import java.util.Objects import java.util.regex.Pattern -import org.opendaylight.yangtools.binding.generator.util.TypeConstants +import org.opendaylight.mdsal.binding.generator.util.TypeConstants import org.opendaylight.mdsal.binding.model.api.ConcreteType import org.opendaylight.mdsal.binding.model.api.Constant import org.opendaylight.mdsal.binding.model.api.Enumeration diff --git a/binding/mdsal-binding-java-api-generator/src/main/java/org/opendaylight/yangtools/sal/java/api/generator/EnumTemplate.xtend b/binding/mdsal-binding-java-api-generator/src/main/java/org/opendaylight/yangtools/sal/java/api/generator/EnumTemplate.xtend index 3bb58301b0..8a46e4d069 100644 --- a/binding/mdsal-binding-java-api-generator/src/main/java/org/opendaylight/yangtools/sal/java/api/generator/EnumTemplate.xtend +++ b/binding/mdsal-binding-java-api-generator/src/main/java/org/opendaylight/yangtools/sal/java/api/generator/EnumTemplate.xtend @@ -7,7 +7,7 @@ */ package org.opendaylight.yangtools.sal.java.api.generator -import static org.opendaylight.yangtools.binding.generator.util.BindingGeneratorUtil.encodeAngleBrackets; +import static org.opendaylight.mdsal.binding.generator.util.BindingGeneratorUtil.encodeAngleBrackets; import org.opendaylight.mdsal.binding.model.api.Enumeration import org.opendaylight.mdsal.binding.model.api.GeneratedType diff --git a/binding/mdsal-binding-java-api-generator/src/main/java/org/opendaylight/yangtools/sal/java/api/generator/GeneratorUtil.java b/binding/mdsal-binding-java-api-generator/src/main/java/org/opendaylight/yangtools/sal/java/api/generator/GeneratorUtil.java index 0583926111..1445da95bf 100644 --- a/binding/mdsal-binding-java-api-generator/src/main/java/org/opendaylight/yangtools/sal/java/api/generator/GeneratorUtil.java +++ b/binding/mdsal-binding-java-api-generator/src/main/java/org/opendaylight/yangtools/sal/java/api/generator/GeneratorUtil.java @@ -14,6 +14,8 @@ import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import org.opendaylight.mdsal.binding.generator.util.TypeConstants; +import org.opendaylight.mdsal.binding.generator.util.Types; import org.opendaylight.mdsal.binding.model.api.AnnotationType; import org.opendaylight.mdsal.binding.model.api.Constant; import org.opendaylight.mdsal.binding.model.api.GeneratedProperty; @@ -23,8 +25,6 @@ import org.opendaylight.mdsal.binding.model.api.MethodSignature; import org.opendaylight.mdsal.binding.model.api.ParameterizedType; import org.opendaylight.mdsal.binding.model.api.Type; import org.opendaylight.mdsal.binding.model.api.WildcardType; -import org.opendaylight.yangtools.binding.generator.util.TypeConstants; -import org.opendaylight.yangtools.binding.generator.util.Types; public final class GeneratorUtil { diff --git a/binding/mdsal-binding-java-api-generator/src/main/java/org/opendaylight/yangtools/sal/java/api/generator/InterfaceTemplate.xtend b/binding/mdsal-binding-java-api-generator/src/main/java/org/opendaylight/yangtools/sal/java/api/generator/InterfaceTemplate.xtend index 4c69d08a67..9af6b7590c 100644 --- a/binding/mdsal-binding-java-api-generator/src/main/java/org/opendaylight/yangtools/sal/java/api/generator/InterfaceTemplate.xtend +++ b/binding/mdsal-binding-java-api-generator/src/main/java/org/opendaylight/yangtools/sal/java/api/generator/InterfaceTemplate.xtend @@ -8,7 +8,7 @@ package org.opendaylight.yangtools.sal.java.api.generator import java.util.List -import org.opendaylight.yangtools.binding.generator.util.TypeConstants +import org.opendaylight.mdsal.binding.generator.util.TypeConstants import org.opendaylight.mdsal.binding.model.api.Constant import org.opendaylight.mdsal.binding.model.api.Enumeration import org.opendaylight.mdsal.binding.model.api.GeneratedTransferObject diff --git a/binding/mdsal-binding-java-api-generator/src/main/java/org/opendaylight/yangtools/sal/java/api/generator/UnionTemplate.xtend b/binding/mdsal-binding-java-api-generator/src/main/java/org/opendaylight/yangtools/sal/java/api/generator/UnionTemplate.xtend index 29d8b2e51a..adece1133b 100644 --- a/binding/mdsal-binding-java-api-generator/src/main/java/org/opendaylight/yangtools/sal/java/api/generator/UnionTemplate.xtend +++ b/binding/mdsal-binding-java-api-generator/src/main/java/org/opendaylight/yangtools/sal/java/api/generator/UnionTemplate.xtend @@ -7,7 +7,8 @@ */ package org.opendaylight.yangtools.sal.java.api.generator -import static org.opendaylight.yangtools.binding.generator.util.Types.* +import static org.opendaylight.mdsal.binding.generator.util.Types.* + import com.google.common.base.Preconditions; import java.beans.ConstructorProperties import org.opendaylight.mdsal.binding.model.api.GeneratedProperty diff --git a/binding/mdsal-binding-java-api-generator/src/main/java/org/opendaylight/yangtools/sal/java/api/generator/YangModuleInfoTemplate.xtend b/binding/mdsal-binding-java-api-generator/src/main/java/org/opendaylight/yangtools/sal/java/api/generator/YangModuleInfoTemplate.xtend index c40abe4b20..5bc718d195 100644 --- a/binding/mdsal-binding-java-api-generator/src/main/java/org/opendaylight/yangtools/sal/java/api/generator/YangModuleInfoTemplate.xtend +++ b/binding/mdsal-binding-java-api-generator/src/main/java/org/opendaylight/yangtools/sal/java/api/generator/YangModuleInfoTemplate.xtend @@ -27,7 +27,7 @@ import java.util.Map import java.util.Set import java.util.TreeMap import java.util.function.Function -import org.opendaylight.yangtools.binding.generator.util.Types +import org.opendaylight.mdsal.binding.generator.util.Types import org.opendaylight.mdsal.binding.model.api.ParameterizedType import org.opendaylight.mdsal.binding.model.api.Type import org.opendaylight.mdsal.binding.model.api.WildcardType diff --git a/binding/mdsal-binding-java-api-generator/src/test/java/org/opendaylight/yangtools/sal/java/api/generator/GeneratorUtilTest.java b/binding/mdsal-binding-java-api-generator/src/test/java/org/opendaylight/yangtools/sal/java/api/generator/GeneratorUtilTest.java index 5c71ce4c61..bc6e471ad8 100644 --- a/binding/mdsal-binding-java-api-generator/src/test/java/org/opendaylight/yangtools/sal/java/api/generator/GeneratorUtilTest.java +++ b/binding/mdsal-binding-java-api-generator/src/test/java/org/opendaylight/yangtools/sal/java/api/generator/GeneratorUtilTest.java @@ -14,7 +14,7 @@ import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.reset; -import static org.opendaylight.yangtools.binding.generator.util.TypeConstants.PATTERN_CONSTANT_NAME; +import static org.opendaylight.mdsal.binding.generator.util.TypeConstants.PATTERN_CONSTANT_NAME; import static org.opendaylight.yangtools.sal.java.api.generator.GeneratorUtil.createImports; import com.google.common.collect.ImmutableList; diff --git a/binding/mdsal-binding-java-api-generator/src/test/java/org/opendaylight/yangtools/sal/java/api/generator/test/ClassCodeGeneratorTest.java b/binding/mdsal-binding-java-api-generator/src/test/java/org/opendaylight/yangtools/sal/java/api/generator/test/ClassCodeGeneratorTest.java index 1e62762404..ba40eca7d8 100644 --- a/binding/mdsal-binding-java-api-generator/src/test/java/org/opendaylight/yangtools/sal/java/api/generator/test/ClassCodeGeneratorTest.java +++ b/binding/mdsal-binding-java-api-generator/src/test/java/org/opendaylight/yangtools/sal/java/api/generator/test/ClassCodeGeneratorTest.java @@ -20,14 +20,14 @@ import java.util.List; import org.junit.BeforeClass; import org.junit.Test; import org.opendaylight.mdsal.binding.generator.api.BindingGenerator; +import org.opendaylight.mdsal.binding.generator.util.Types; +import org.opendaylight.mdsal.binding.generator.util.generated.type.builder.GeneratedTOBuilderImpl; import org.opendaylight.mdsal.binding.model.api.GeneratedProperty; import org.opendaylight.mdsal.binding.model.api.GeneratedTransferObject; import org.opendaylight.mdsal.binding.model.api.GeneratedType; import org.opendaylight.mdsal.binding.model.api.Type; import org.opendaylight.mdsal.binding.model.api.type.builder.GeneratedPropertyBuilder; import org.opendaylight.mdsal.binding.model.api.type.builder.GeneratedTOBuilder; -import org.opendaylight.yangtools.binding.generator.util.Types; -import org.opendaylight.yangtools.binding.generator.util.generated.type.builder.GeneratedTOBuilderImpl; import org.opendaylight.yangtools.sal.binding.generator.impl.BindingGeneratorImpl; import org.opendaylight.yangtools.sal.java.api.generator.TOGenerator; import org.opendaylight.yangtools.yang.model.api.SchemaContext; diff --git a/binding/mdsal-binding-java-api-generator/src/test/java/org/opendaylight/yangtools/sal/java/api/generator/test/GeneratorJavaFileTest.java b/binding/mdsal-binding-java-api-generator/src/test/java/org/opendaylight/yangtools/sal/java/api/generator/test/GeneratorJavaFileTest.java index 553e8cd104..ac369deaf4 100644 --- a/binding/mdsal-binding-java-api-generator/src/test/java/org/opendaylight/yangtools/sal/java/api/generator/test/GeneratorJavaFileTest.java +++ b/binding/mdsal-binding-java-api-generator/src/test/java/org/opendaylight/yangtools/sal/java/api/generator/test/GeneratorJavaFileTest.java @@ -16,11 +16,11 @@ import java.util.HashSet; import java.util.List; import java.util.Set; import org.junit.Test; +import org.opendaylight.mdsal.binding.generator.util.BindingTypes; +import org.opendaylight.mdsal.binding.generator.util.Types; +import org.opendaylight.mdsal.binding.generator.util.generated.type.builder.GeneratedTypeBuilderImpl; import org.opendaylight.mdsal.binding.model.api.GeneratedType; import org.opendaylight.mdsal.binding.model.api.type.builder.GeneratedTypeBuilder; -import org.opendaylight.yangtools.binding.generator.util.BindingTypes; -import org.opendaylight.yangtools.binding.generator.util.Types; -import org.opendaylight.yangtools.binding.generator.util.generated.type.builder.GeneratedTypeBuilderImpl; import org.opendaylight.yangtools.sal.java.api.generator.GeneratorJavaFile; public class GeneratorJavaFileTest { -- 2.36.6