X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=opendaylight%2Fsal%2Fyang-prototype%2Fcode-generator%2Fbinding-generator-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Fbinding%2Fgenerator%2Fimpl%2FGeneratedTypeBuilderImpl.java;fp=opendaylight%2Fsal%2Fyang-prototype%2Fcode-generator%2Fbinding-generator-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Fbinding%2Fgenerator%2Fimpl%2FGeneratedTypeBuilderImpl.java;h=0000000000000000000000000000000000000000;hb=7ca1c91122b68d3d7c3ef403114cf4af95174230;hp=1b8246ab2b072ef85e505eb5e9276491293f233e;hpb=4221068644c7e8d08880b4d54e2a099a646796b9;p=controller.git diff --git a/opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/main/java/org/opendaylight/controller/sal/binding/generator/impl/GeneratedTypeBuilderImpl.java b/opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/main/java/org/opendaylight/controller/sal/binding/generator/impl/GeneratedTypeBuilderImpl.java deleted file mode 100644 index 1b8246ab2b..0000000000 --- a/opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/main/java/org/opendaylight/controller/sal/binding/generator/impl/GeneratedTypeBuilderImpl.java +++ /dev/null @@ -1,310 +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.controller.sal.binding.generator.impl; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import org.opendaylight.controller.sal.binding.model.api.AnnotationType; -import org.opendaylight.controller.sal.binding.model.api.Constant; -import org.opendaylight.controller.sal.binding.model.api.Enumeration; -import org.opendaylight.controller.sal.binding.model.api.GeneratedType; -import org.opendaylight.controller.sal.binding.model.api.MethodSignature; -import org.opendaylight.controller.sal.binding.model.api.Type; -import org.opendaylight.controller.sal.binding.model.api.type.builder.AnnotationTypeBuilder; -import org.opendaylight.controller.sal.binding.model.api.type.builder.ConstantBuilder; -import org.opendaylight.controller.sal.binding.model.api.type.builder.EnumBuilder; -import org.opendaylight.controller.sal.binding.model.api.type.builder.GeneratedTypeBuilder; -import org.opendaylight.controller.sal.binding.model.api.type.builder.MethodSignatureBuilder; - -public final class GeneratedTypeBuilderImpl implements GeneratedTypeBuilder { - - private final String packageName; - private String comment = ""; - private final String name; - private final List annotationBuilders = new ArrayList(); - private final List enumDefinitions = new ArrayList(); - private final List constantDefintions = new ArrayList(); - private final List methodDefinitions = new ArrayList(); - - public GeneratedTypeBuilderImpl(final String packageName, final String name) { - this.packageName = packageName; - this.name = name; - } - - @Override - public Type getParentType() { - return this; - } - - @Override - public String getPackageName() { - return packageName; - } - - @Override - public String getName() { - return name; - } - - @Override - public void addComment(String comment) { - this.comment = comment; - } - - @Override - public AnnotationTypeBuilder addAnnotation(String packageName, String name) { - if (packageName != null && name != null) { - final AnnotationTypeBuilder builder = new AnnotationTypeBuilderImpl( - packageName, name); - if (annotationBuilders.add(builder)) { - return builder; - } - } - return null; - } - - @Override - public ConstantBuilder addConstant(Type type, String name, Object value) { - final ConstantBuilder builder = new ConstantBuilderImpl(type, name, - value); - constantDefintions.add(builder); - return builder; - } - - @Override - public EnumBuilder addEnumeration(final String name) { - final String innerPackageName = packageName + "." + this.name; - final EnumBuilder builder = new EnumerationBuilderImpl( - innerPackageName, name); - enumDefinitions.add(builder); - return builder; - } - - @Override - public MethodSignatureBuilder addMethod(final String name) { - final MethodSignatureBuilder builder = new MethodSignatureBuilderImpl( - this, name); - methodDefinitions.add(builder); - return builder; - } - - @Override - public GeneratedType toInstance() { - return new GeneratedTypeImpl(this, packageName, name, comment, - annotationBuilders, enumDefinitions, constantDefintions, - methodDefinitions); - } - - private static final class GeneratedTypeImpl implements GeneratedType { - - private final Type parent; - private final String packageName; - private final String name; - private final String comment; - private final List annotations; - private final List enumDefinitions; - private final List constantDefintions; - private final List methodDefinitions; - - public GeneratedTypeImpl(final Type parent, final String packageName, - final String name, final String comment, - final List annotationBuilders, - final List enumBuilders, - final List constantBuilders, - final List methodBuilders) { - super(); - this.parent = parent; - this.packageName = packageName; - this.name = name; - this.comment = comment; - this.annotations = toUnmodifiableAnnotations(annotationBuilders); - this.constantDefintions = toUnmodifiableConstants(constantBuilders); - this.enumDefinitions = toUnmodifiableEnums(enumBuilders); - this.methodDefinitions = toUnmodifiableMethods(methodBuilders); - } - - private List toUnmodifiableAnnotations( - final List annotationBuilders) { - final List annotations = new ArrayList(); - for (final AnnotationTypeBuilder builder : annotationBuilders) { - annotations.add(builder.toInstance()); - } - return Collections.unmodifiableList(annotations); - } - - private List toUnmodifiableMethods( - List methodBuilders) { - final List methods = new ArrayList(); - for (final MethodSignatureBuilder methodBuilder : methodBuilders) { - methods.add(methodBuilder.toInstance(this)); - } - return Collections.unmodifiableList(methods); - } - - private List toUnmodifiableEnums( - List enumBuilders) { - final List enums = new ArrayList(); - for (final EnumBuilder enumBuilder : enumBuilders) { - enums.add(enumBuilder.toInstance(this)); - } - return Collections.unmodifiableList(enums); - } - - private List toUnmodifiableConstants( - List constantBuilders) { - final List constants = new ArrayList(); - for (final ConstantBuilder enumBuilder : constantBuilders) { - constants.add(enumBuilder.toInstance(this)); - } - return Collections.unmodifiableList(constants); - } - - @Override - public String getPackageName() { - return packageName; - } - - @Override - public String getName() { - return name; - } - - @Override - public Type getParentType() { - return parent; - } - - @Override - public String getComment() { - return comment; - } - - @Override - public List getAnnotations() { - return annotations; - } - - @Override - public List getEnumDefintions() { - return enumDefinitions; - } - - @Override - public List getConstantDefinitions() { - return constantDefintions; - } - - @Override - public List getMethodDefinitions() { - return methodDefinitions; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime - * result - + ((constantDefintions == null) ? 0 : constantDefintions - .hashCode()); - result = prime - * result - + ((enumDefinitions == null) ? 0 : enumDefinitions - .hashCode()); - result = prime - * result - + ((methodDefinitions == null) ? 0 : methodDefinitions - .hashCode()); - result = prime * result + ((name == null) ? 0 : name.hashCode()); - result = prime * result - + ((packageName == null) ? 0 : packageName.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - GeneratedTypeImpl other = (GeneratedTypeImpl) obj; - if (constantDefintions == null) { - if (other.constantDefintions != null) { - return false; - } - } else if (!constantDefintions.equals(other.constantDefintions)) { - return false; - } - if (enumDefinitions == null) { - if (other.enumDefinitions != null) { - return false; - } - } else if (!enumDefinitions.equals(other.enumDefinitions)) { - return false; - } - if (methodDefinitions == null) { - if (other.methodDefinitions != null) { - return false; - } - } else if (!methodDefinitions.equals(other.methodDefinitions)) { - return false; - } - if (name == null) { - if (other.name != null) { - return false; - } - } else if (!name.equals(other.name)) { - return false; - } - if (packageName == null) { - if (other.packageName != null) { - return false; - } - } else if (!packageName.equals(other.packageName)) { - return false; - } - return true; - } - - @Override - public String toString() { - StringBuilder builder = new StringBuilder(); - builder.append("GeneratedType [packageName="); - builder.append(packageName); - builder.append(", name="); - builder.append(name); - if (parent != null) { - builder.append(", parent="); - builder.append(parent.getPackageName()); - builder.append("."); - builder.append(parent.getName()); - } else { - builder.append(", parent=null"); - } - builder.append(", comment="); - builder.append(comment); - builder.append(", annotations="); - builder.append(annotations); - builder.append(", enumDefinitions="); - builder.append(enumDefinitions); - builder.append(", constantDefintions="); - builder.append(constantDefintions); - builder.append(", methodDefinitions="); - builder.append(methodDefinitions); - builder.append("]"); - return builder.toString(); - } - } -}