X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fsal%2Fyang-prototype%2Fcode-generator%2Fbinding-generator-util%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fbinding%2Fgenerator%2Futil%2Fgenerated%2Ftype%2Fbuilder%2FMethodSignatureBuilderImpl.java;h=ebb68647bfe8d9206e27500494f08e95e26fec06;hp=a2ce27c72a54e746094aac07059dac79eab1a6af;hb=f607c4b0b922281f1ddd5fda2e7b49ca67d26ecd;hpb=7ca1c91122b68d3d7c3ef403114cf4af95174230 diff --git a/opendaylight/sal/yang-prototype/code-generator/binding-generator-util/src/main/java/org/opendaylight/controller/binding/generator/util/generated/type/builder/MethodSignatureBuilderImpl.java b/opendaylight/sal/yang-prototype/code-generator/binding-generator-util/src/main/java/org/opendaylight/controller/binding/generator/util/generated/type/builder/MethodSignatureBuilderImpl.java index a2ce27c72a..ebb68647bf 100644 --- a/opendaylight/sal/yang-prototype/code-generator/binding-generator-util/src/main/java/org/opendaylight/controller/binding/generator/util/generated/type/builder/MethodSignatureBuilderImpl.java +++ b/opendaylight/sal/yang-prototype/code-generator/binding-generator-util/src/main/java/org/opendaylight/controller/binding/generator/util/generated/type/builder/MethodSignatureBuilderImpl.java @@ -1,49 +1,34 @@ +/* + * 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.binding.generator.util.generated.type.builder; import java.util.ArrayList; -import java.util.Collections; import java.util.List; -import org.opendaylight.controller.sal.binding.model.api.AccessModifier; import org.opendaylight.controller.sal.binding.model.api.AnnotationType; 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.MethodSignatureBuilder; -final class MethodSignatureBuilderImpl implements MethodSignatureBuilder { - private final String name; - private Type returnType; +final class MethodSignatureBuilderImpl extends AbstractTypeMemberBuilder implements MethodSignatureBuilder { + private final List parameters; - private final List annotationBuilders; - private String comment = ""; - private final Type parent; + private boolean isAbstract; - public MethodSignatureBuilderImpl(final Type parent, final String name) { - super(); - this.name = name; - this.parent = parent; - this.parameters = new ArrayList(); - this.annotationBuilders = new ArrayList(); + public MethodSignatureBuilderImpl(final String name) { + super(name); + this.parameters = new ArrayList<>(); } @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 void addReturnType(Type returnType) { - if (returnType != null) { - this.returnType = returnType; - } + public void setAbstract(boolean isAbstract) { + this.isAbstract = isAbstract; } @Override @@ -51,26 +36,22 @@ final class MethodSignatureBuilderImpl implements MethodSignatureBuilder { parameters.add(new MethodParameterImpl(name, type)); } - @Override - public void addComment(String comment) { - this.comment = comment; - } - @Override public MethodSignature toInstance(Type definingType) { - return new MethodSignatureImpl(definingType, name, annotationBuilders, - comment, returnType, parameters); + final List annotations = toAnnotationTypes(); + return new MethodSignatureImpl(definingType, getName(), annotations, + getComment(), getAccessModifier(), getReturnType(), parameters, isFinal(), isAbstract); } @Override public int hashCode() { final int prime = 31; int result = 1; - result = prime * result + ((name == null) ? 0 : name.hashCode()); + result = prime * result + ((getName() == null) ? 0 : getName().hashCode()); result = prime * result + ((parameters == null) ? 0 : parameters.hashCode()); result = prime * result - + ((returnType == null) ? 0 : returnType.hashCode()); + + ((getReturnType() == null) ? 0 : getReturnType().hashCode()); return result; } @@ -86,11 +67,11 @@ final class MethodSignatureBuilderImpl implements MethodSignatureBuilder { return false; } MethodSignatureBuilderImpl other = (MethodSignatureBuilderImpl) obj; - if (name == null) { - if (other.name != null) { + if (getName() == null) { + if (other.getName() != null) { return false; } - } else if (!name.equals(other.name)) { + } else if (!getName().equals(other.getName())) { return false; } if (parameters == null) { @@ -100,11 +81,11 @@ final class MethodSignatureBuilderImpl implements MethodSignatureBuilder { } else if (!parameters.equals(other.parameters)) { return false; } - if (returnType == null) { - if (other.returnType != null) { + if (getReturnType() == null) { + if (other.getReturnType() != null) { return false; } - } else if (!returnType.equals(other.returnType)) { + } else if (!getReturnType().equals(other.getReturnType())) { return false; } return true; @@ -114,160 +95,16 @@ final class MethodSignatureBuilderImpl implements MethodSignatureBuilder { public String toString() { StringBuilder builder = new StringBuilder(); builder.append("MethodSignatureBuilderImpl [name="); - builder.append(name); + builder.append(getName()); builder.append(", returnType="); - builder.append(returnType); + builder.append(getReturnType()); builder.append(", parameters="); builder.append(parameters); builder.append(", annotationBuilders="); - builder.append(annotationBuilders); + builder.append(getAnnotationBuilders()); builder.append(", comment="); - builder.append(comment); - if (parent != null) { - builder.append(", parent="); - builder.append(parent.getPackageName()); - builder.append("."); - builder.append(parent.getName()); - } else { - builder.append(", parent=null"); - } + builder.append(getComment()); builder.append("]"); return builder.toString(); } - - private static final class MethodSignatureImpl implements MethodSignature { - - private final String name; - private final String comment; - private final Type definingType; - private final Type returnType; - private final List params; - private List annotations; - - public MethodSignatureImpl(final Type definingType, final String name, - final List annotationBuilders, - final String comment, final Type returnType, - final List params) { - super(); - this.name = name; - this.comment = comment; - this.definingType = definingType; - this.returnType = returnType; - this.params = Collections.unmodifiableList(params); - - this.annotations = new ArrayList(); - for (final AnnotationTypeBuilder builder : annotationBuilders) { - this.annotations.add(builder.toInstance()); - } - this.annotations = Collections.unmodifiableList(this.annotations); - } - - @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 Type getReturnType() { - return returnType; - } - - @Override - public List getParameters() { - return params; - } - - @Override - public AccessModifier getAccessModifier() { - return AccessModifier.PUBLIC; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((name == null) ? 0 : name.hashCode()); - result = prime * result - + ((params == null) ? 0 : params.hashCode()); - result = prime * result - + ((returnType == null) ? 0 : returnType.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; - } - MethodSignatureImpl other = (MethodSignatureImpl) obj; - if (name == null) { - if (other.name != null) { - return false; - } - } else if (!name.equals(other.name)) { - return false; - } - if (params == null) { - if (other.params != null) { - return false; - } - } else if (!params.equals(other.params)) { - return false; - } - if (returnType == null) { - if (other.returnType != null) { - return false; - } - } else if (!returnType.equals(other.returnType)) { - return false; - } - return true; - } - - @Override - public String toString() { - StringBuilder builder = new StringBuilder(); - builder.append("MethodSignatureImpl [name="); - builder.append(name); - builder.append(", comment="); - builder.append(comment); - if (definingType != null) { - builder.append(", definingType="); - builder.append(definingType.getPackageName()); - builder.append("."); - builder.append(definingType.getName()); - } else { - builder.append(", definingType= null"); - } - builder.append(", returnType="); - builder.append(returnType); - builder.append(", params="); - builder.append(params); - builder.append(", annotations="); - builder.append(annotations); - builder.append("]"); - return builder.toString(); - } - } } \ No newline at end of file