X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fsal%2Fyang-prototype%2Fcode-generator%2Fbinding-generator-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Fbinding%2Fgenerator%2Fimpl%2FConstantBuilderImpl.java;h=cbe704aff1c26a3d36851e80fbd38e43667edb07;hp=cb2fc872b9908eac90a117622b5598ac78b4ebac;hb=4221068644c7e8d08880b4d54e2a099a646796b9;hpb=42210c03b0a4c54706320ba9f55794c0abd4d201 diff --git a/opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/main/java/org/opendaylight/controller/sal/binding/generator/impl/ConstantBuilderImpl.java b/opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/main/java/org/opendaylight/controller/sal/binding/generator/impl/ConstantBuilderImpl.java index cb2fc872b9..cbe704aff1 100644 --- a/opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/main/java/org/opendaylight/controller/sal/binding/generator/impl/ConstantBuilderImpl.java +++ b/opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/main/java/org/opendaylight/controller/sal/binding/generator/impl/ConstantBuilderImpl.java @@ -1,189 +1,166 @@ -/* - * 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 org.opendaylight.controller.sal.binding.model.api.Constant; -import org.opendaylight.controller.sal.binding.model.api.Type; -import org.opendaylight.controller.sal.binding.model.api.type.builder.ConstantBuilder; - -final class ConstantBuilderImpl implements ConstantBuilder { - - private final Type type; - private final String name; - private Object value; - - public ConstantBuilderImpl(Type type, String name, Object value) { - super(); - this.type = type; - this.name = name; - this.value = value; - } - - public ConstantBuilderImpl(Type type, String name) { - super(); - this.type = type; - this.name = name; - } - - @Override - public void assignValue(Object value) { - this.value = value; - } - - @Override - public Constant toInstance(final Type definingType) { - return new ConstantImpl(definingType, type, name, value); - } - - private static final class ConstantImpl implements Constant { - - 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 + ((name == null) ? 0 : name.hashCode()); - result = prime * result + ((type == null) ? 0 : type.hashCode()); - result = prime * result + ((value == null) ? 0 : value.hashCode()); - if (definingType != null) { - result = prime - * result - + ((definingType.getPackageName() == null) ? 0 - : definingType.getPackageName().hashCode()); - result = prime - * result - + ((definingType.getName() == null) ? 0 : definingType - .getName().hashCode()); - } - return result; - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - ConstantImpl other = (ConstantImpl) obj; - if (name == null) { - if (other.name != null) { - return false; - } - } else if (!name.equals(other.name)) { - return false; - } - if (type == null) { - if (other.type != null) { - return false; - } - } else if (!type.equals(other.type)) { - return false; - } - if (value == null) { - if (other.value != null) { - return false; - } - } else if (!value.equals(other.value)) { - return false; - } - if (definingType == null) { - if (other.definingType != null) { - return false; - } - } else if ((definingType != null) && (other.definingType != null)) { - if (!definingType.getPackageName().equals( - other.definingType.getPackageName()) - && !definingType.getName().equals( - other.definingType.getName())) { - return false; - } - } - return true; - } - - @Override - public String toString() { - StringBuilder builder = new StringBuilder(); - builder.append("ConstantImpl [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(); - } - } -} +/* + * 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 org.opendaylight.controller.sal.binding.model.api.Constant; +import org.opendaylight.controller.sal.binding.model.api.Type; +import org.opendaylight.controller.sal.binding.model.api.type.builder.ConstantBuilder; + +final class ConstantBuilderImpl implements ConstantBuilder { + + private final Type type; + private final String name; + private Object value; + + public ConstantBuilderImpl(Type type, String name, Object value) { + super(); + this.type = type; + this.name = name; + this.value = value; + } + + public ConstantBuilderImpl(Type type, String name) { + super(); + this.type = type; + this.name = name; + } + + @Override + public void assignValue(Object value) { + this.value = value; + } + + @Override + public Constant toInstance(final Type definingType) { + return new ConstantImpl(definingType, type, name, value); + } + + private static final class ConstantImpl implements Constant { + + 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 + ((name == null) ? 0 : name.hashCode()); + result = prime * result + ((type == null) ? 0 : type.hashCode()); + return result; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + ConstantImpl other = (ConstantImpl) obj; + if (name == null) { + if (other.name != null) { + return false; + } + } else if (!name.equals(other.name)) { + return false; + } + if (type == null) { + if (other.type != null) { + return false; + } + } else if (!type.equals(other.type)) { + return false; + } + if (value == null) { + if (other.value != null) { + return false; + } + } else if (!value.equals(other.value)) { + return false; + } + return true; + } + + @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(); + } + } +}