-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.sal.binding.generator.impl;\r
-\r
-import org.opendaylight.controller.sal.binding.model.api.Constant;\r
-import org.opendaylight.controller.sal.binding.model.api.Type;\r
-import org.opendaylight.controller.sal.binding.model.api.type.builder.ConstantBuilder;\r
-\r
-final class ConstantBuilderImpl implements ConstantBuilder {\r
-\r
- private final Type type;\r
- private final String name;\r
- private Object value;\r
-\r
- public ConstantBuilderImpl(Type type, String name, Object value) {\r
- super();\r
- this.type = type;\r
- this.name = name;\r
- this.value = value;\r
- }\r
-\r
- public ConstantBuilderImpl(Type type, String name) {\r
- super();\r
- this.type = type;\r
- this.name = name;\r
- }\r
-\r
- @Override\r
- public void assignValue(Object value) {\r
- this.value = value;\r
- }\r
-\r
- @Override\r
- public Constant toInstance(final Type definingType) {\r
- return new ConstantImpl(definingType, type, name, value);\r
- }\r
-\r
- private static final class ConstantImpl implements Constant {\r
-\r
- final Type definingType;\r
- private final Type type;\r
- private final String name;\r
- private final Object value;\r
-\r
- public ConstantImpl(final Type definingType, final Type type,\r
- final String name, final Object value) {\r
- super();\r
- this.definingType = definingType;\r
- this.type = type;\r
- this.name = name;\r
- this.value = value;\r
- }\r
-\r
- @Override\r
- public Type getDefiningType() {\r
- return definingType;\r
- }\r
-\r
- @Override\r
- public Type getType() {\r
- return type;\r
- }\r
-\r
- @Override\r
- public String getName() {\r
- return name;\r
- }\r
-\r
- @Override\r
- public Object getValue() {\r
- return value;\r
- }\r
-\r
- @Override\r
- public String toFormattedString() {\r
- StringBuilder builder = new StringBuilder();\r
- builder.append(type);\r
- builder.append(" ");\r
- builder.append(name);\r
- builder.append(" ");\r
- builder.append(value);\r
- return builder.toString();\r
- }\r
-\r
- /*\r
- * (non-Javadoc)\r
- * \r
- * @see java.lang.Object#hashCode()\r
- */\r
- @Override\r
- public int hashCode() {\r
- final int prime = 31;\r
- int result = 1;\r
- result = prime * result + ((name == null) ? 0 : name.hashCode());\r
- result = prime * result + ((type == null) ? 0 : type.hashCode());\r
- result = prime * result + ((value == null) ? 0 : value.hashCode());\r
- if (definingType != null) {\r
- result = prime\r
- * result\r
- + ((definingType.getPackageName() == null) ? 0\r
- : definingType.getPackageName().hashCode());\r
- result = prime\r
- * result\r
- + ((definingType.getName() == null) ? 0 : definingType\r
- .getName().hashCode());\r
- }\r
- return result;\r
- }\r
-\r
- /*\r
- * (non-Javadoc)\r
- * \r
- * @see java.lang.Object#equals(java.lang.Object)\r
- */\r
- @Override\r
- public boolean equals(Object obj) {\r
- if (this == obj) {\r
- return true;\r
- }\r
- if (obj == null) {\r
- return false;\r
- }\r
- if (getClass() != obj.getClass()) {\r
- return false;\r
- }\r
- ConstantImpl other = (ConstantImpl) obj;\r
- if (name == null) {\r
- if (other.name != null) {\r
- return false;\r
- }\r
- } else if (!name.equals(other.name)) {\r
- return false;\r
- }\r
- if (type == null) {\r
- if (other.type != null) {\r
- return false;\r
- }\r
- } else if (!type.equals(other.type)) {\r
- return false;\r
- }\r
- if (value == null) {\r
- if (other.value != null) {\r
- return false;\r
- }\r
- } else if (!value.equals(other.value)) {\r
- return false;\r
- }\r
- if (definingType == null) {\r
- if (other.definingType != null) {\r
- return false;\r
- }\r
- } else if ((definingType != null) && (other.definingType != null)) {\r
- if (!definingType.getPackageName().equals(\r
- other.definingType.getPackageName())\r
- && !definingType.getName().equals(\r
- other.definingType.getName())) {\r
- return false;\r
- }\r
- }\r
- return true;\r
- }\r
-\r
- @Override\r
- public String toString() {\r
- StringBuilder builder = new StringBuilder();\r
- builder.append("ConstantImpl [type=");\r
- builder.append(type);\r
- builder.append(", name=");\r
- builder.append(name);\r
- builder.append(", value=");\r
- builder.append(value);\r
- if (definingType != null) {\r
- builder.append(", definingType=");\r
- builder.append(definingType.getPackageName());\r
- builder.append(".");\r
- builder.append(definingType.getName());\r
- } else {\r
- builder.append(", definingType= null");\r
- }\r
- builder.append("]");\r
- return builder.toString();\r
- }\r
- }\r
-}\r
+/*
+ * 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();
+ }
+ }
+}