+++ /dev/null
-/*\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.model.util;\r
-\r
-import java.util.Collections;\r
-import java.util.List;\r
-\r
-import org.opendaylight.controller.yang.common.QName;\r
-import org.opendaylight.controller.yang.model.api.SchemaPath;\r
-import org.opendaylight.controller.yang.model.api.Status;\r
-import org.opendaylight.controller.yang.model.api.TypeDefinition;\r
-import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;\r
-\r
-public class ExtendedType implements TypeDefinition {\r
-\r
- private final QName typeName;\r
- private final TypeDefinition<?> baseType;\r
- private final SchemaPath path;\r
- private final String description;\r
- private final String reference;\r
- private final List<UnknownSchemaNode> unknownSchemaNodes;\r
-\r
- private Status status;\r
- private String units;\r
- private Object defaultValue;\r
-\r
- public static class Builder {\r
- private final QName typeName;\r
- private final TypeDefinition<?> baseType;\r
-\r
- private final SchemaPath path;\r
- private final String description;\r
- private final String reference;\r
-\r
- private List<UnknownSchemaNode> unknownSchemaNodes = Collections.emptyList();;\r
- private Status status = Status.CURRENT;\r
- private String units = "";\r
- private Object defaultValue = null;\r
-\r
- public Builder(final QName typeName, TypeDefinition<?> baseType,\r
- final String description, final String reference) {\r
- this.typeName = typeName;\r
- this.baseType = baseType;\r
- this.path = BaseTypes.schemaPath(typeName);\r
- this.description = description;\r
- this.reference = reference;\r
- }\r
-\r
- public Builder status(Status status) {\r
- this.status = status;\r
- return this;\r
- }\r
-\r
- public Builder units(String units) {\r
- this.units = units;\r
- return this;\r
- }\r
-\r
- public Builder defaultValue(final Object defaultValue) {\r
- this.defaultValue = defaultValue;\r
- return this;\r
- }\r
-\r
- public Builder unknownSchemaNodes(final List<UnknownSchemaNode> unknownSchemaNodes) {\r
- this.unknownSchemaNodes = unknownSchemaNodes;\r
- return this;\r
- }\r
-\r
- public ExtendedType build() {\r
- return new ExtendedType(this);\r
- }\r
- }\r
-\r
- private ExtendedType(Builder builder) {\r
- this.typeName = builder.typeName;\r
- this.baseType = builder.baseType;\r
- this.path = builder.path;\r
- this.description = builder.description;\r
- this.reference = builder.reference;\r
- this.unknownSchemaNodes = builder.unknownSchemaNodes;\r
- this.status = builder.status;\r
- this.units = builder.units;\r
- this.defaultValue = builder.defaultValue;\r
- }\r
-\r
- @Override\r
- public TypeDefinition<?> getBaseType() {\r
- return baseType;\r
- }\r
-\r
- @Override\r
- public String getUnits() {\r
- return units;\r
- }\r
-\r
- @Override\r
- public Object getDefaultValue() {\r
- return defaultValue;\r
- }\r
-\r
- @Override\r
- public QName getQName() {\r
- return typeName;\r
- }\r
-\r
- @Override\r
- public SchemaPath getPath() {\r
- return path;\r
- }\r
-\r
- @Override\r
- public String getDescription() {\r
- return description;\r
- }\r
-\r
- @Override\r
- public String getReference() {\r
- return reference;\r
- }\r
-\r
- @Override\r
- public Status getStatus() {\r
- return status;\r
- }\r
-\r
- @Override\r
- public List<UnknownSchemaNode> getUnknownSchemaNodes() {\r
- return unknownSchemaNodes;\r
- }\r
-\r
- @Override\r
- public int hashCode() {\r
- final int prime = 31;\r
- int result = 1;\r
- result = prime * result\r
- + ((baseType == null) ? 0 : baseType.hashCode());\r
- result = prime * result\r
- + ((defaultValue == null) ? 0 : defaultValue.hashCode());\r
- result = prime * result\r
- + ((description == null) ? 0 : description.hashCode());\r
- result = prime * result\r
- + ((unknownSchemaNodes == null) ? 0 : unknownSchemaNodes.hashCode());\r
- result = prime * result + ((path == null) ? 0 : path.hashCode());\r
- result = prime * result\r
- + ((reference == null) ? 0 : reference.hashCode());\r
- result = prime * result + ((status == null) ? 0 : status.hashCode());\r
- result = prime * result\r
- + ((typeName == null) ? 0 : typeName.hashCode());\r
- result = prime * result + ((units == null) ? 0 : units.hashCode());\r
- return result;\r
- }\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
- ExtendedType other = (ExtendedType) obj;\r
- if (baseType == null) {\r
- if (other.baseType != null) {\r
- return false;\r
- }\r
- } else if (!baseType.equals(other.baseType)) {\r
- return false;\r
- }\r
- if (defaultValue == null) {\r
- if (other.defaultValue != null) {\r
- return false;\r
- }\r
- } else if (!defaultValue.equals(other.defaultValue)) {\r
- return false;\r
- }\r
- if (description == null) {\r
- if (other.description != null) {\r
- return false;\r
- }\r
- } else if (!description.equals(other.description)) {\r
- return false;\r
- }\r
- if (unknownSchemaNodes == null) {\r
- if (other.unknownSchemaNodes != null) {\r
- return false;\r
- }\r
- } else if (!unknownSchemaNodes.equals(other.unknownSchemaNodes)) {\r
- return false;\r
- }\r
- if (path == null) {\r
- if (other.path != null) {\r
- return false;\r
- }\r
- } else if (!path.equals(other.path)) {\r
- return false;\r
- }\r
- if (reference == null) {\r
- if (other.reference != null) {\r
- return false;\r
- }\r
- } else if (!reference.equals(other.reference)) {\r
- return false;\r
- }\r
- if (status != other.status) {\r
- return false;\r
- }\r
- if (typeName == null) {\r
- if (other.typeName != null) {\r
- return false;\r
- }\r
- } else if (!typeName.equals(other.typeName)) {\r
- return false;\r
- }\r
- if (units == null) {\r
- if (other.units != null) {\r
- return false;\r
- }\r
- } else if (!units.equals(other.units)) {\r
- return false;\r
- }\r
- return true;\r
- }\r
-\r
- @Override\r
- public String toString() {\r
- StringBuilder builder2 = new StringBuilder();\r
- builder2.append("ExtendedType [typeName=");\r
- builder2.append(typeName);\r
- builder2.append(", baseType=");\r
- builder2.append(baseType);\r
- builder2.append(", path=");\r
- builder2.append(path);\r
- builder2.append(", description=");\r
- builder2.append(description);\r
- builder2.append(", reference=");\r
- builder2.append(reference);\r
- builder2.append(", unknownSchemaNodes=");\r
- builder2.append(unknownSchemaNodes);\r
- builder2.append(", status=");\r
- builder2.append(status);\r
- builder2.append(", units=");\r
- builder2.append(units);\r
- builder2.append(", defaultValue=");\r
- builder2.append(defaultValue);\r
- builder2.append("]");\r
- return builder2.toString();\r
- }\r
-}\r