X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fsal%2Fyang-prototype%2Fyang%2Fyang-model-util%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fyang%2Fmodel%2Futil%2FExtendedType.java;h=6070c1c6ac563cc230dd7c9ddac921cfb9344911;hb=970fb91c60c15a9b57e078f81aab7dde903addb9;hp=03f06387f1d70a251c82510dbdc5ec61dd3d1a95;hpb=4a5b8b61c06c7091a7de5ed9df7456fa325dd909;p=controller.git diff --git a/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/ExtendedType.java b/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/ExtendedType.java index 03f06387f1..6070c1c6ac 100644 --- a/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/ExtendedType.java +++ b/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/ExtendedType.java @@ -1,13 +1,15 @@ /* - * 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 - */ + * 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.yang.model.util; +import java.net.URI; import java.util.Collections; +import java.util.Date; import java.util.List; import org.opendaylight.controller.yang.common.QName; @@ -19,7 +21,7 @@ import org.opendaylight.controller.yang.model.api.type.LengthConstraint; import org.opendaylight.controller.yang.model.api.type.PatternConstraint; import org.opendaylight.controller.yang.model.api.type.RangeConstraint; -public class ExtendedType implements TypeDefinition { +public class ExtendedType implements TypeDefinition> { private final QName typeName; private final TypeDefinition baseType; @@ -33,10 +35,10 @@ public class ExtendedType implements TypeDefinition { private List patterns = Collections.emptyList(); private Integer fractionDigits = null; - private Status status; private String units; private Object defaultValue; + private boolean addedByUses; public static class Builder { private final QName typeName; @@ -46,21 +48,35 @@ public class ExtendedType implements TypeDefinition { private final String description; private final String reference; - private List unknownSchemaNodes = Collections.emptyList();; + private List unknownSchemaNodes = Collections + .emptyList(); private Status status = Status.CURRENT; - private String units = ""; + private String units = null; private Object defaultValue = null; + private boolean addedByUses; private List ranges = Collections.emptyList(); private List lengths = Collections.emptyList(); private List patterns = Collections.emptyList(); private Integer fractionDigits = null; + public Builder(final List actualPath, final URI namespace, + final Date revision, final QName typeName, + TypeDefinition baseType, final String description, + final String reference) { + this.typeName = typeName; + this.baseType = baseType; + this.path = BaseTypes.schemaPath(actualPath, namespace, revision); + this.description = description; + this.reference = reference; + } + public Builder(final QName typeName, TypeDefinition baseType, - final String description, final String reference) { + final String description, final String reference, + SchemaPath path) { this.typeName = typeName; this.baseType = baseType; - this.path = BaseTypes.schemaPath(typeName); + this.path = path; this.description = description; this.reference = reference; } @@ -80,27 +96,33 @@ public class ExtendedType implements TypeDefinition { return this; } - public Builder unknownSchemaNodes(final List unknownSchemaNodes) { + public Builder addedByUses(final boolean addedByUses) { + this.addedByUses = addedByUses; + return this; + } + + public Builder unknownSchemaNodes( + final List unknownSchemaNodes) { this.unknownSchemaNodes = unknownSchemaNodes; return this; } public Builder ranges(final List ranges) { - if(ranges != null) { + if (ranges != null) { this.ranges = ranges; } return this; } public Builder lengths(final List lengths) { - if(lengths != null) { + if (lengths != null) { this.lengths = lengths; } return this; } public Builder patterns(final List patterns) { - if(patterns != null) { + if (patterns != null) { this.patterns = patterns; } return this; @@ -126,6 +148,7 @@ public class ExtendedType implements TypeDefinition { this.status = builder.status; this.units = builder.units; this.defaultValue = builder.defaultValue; + this.addedByUses = builder.addedByUses; this.ranges = builder.ranges; this.lengths = builder.lengths; @@ -148,6 +171,10 @@ public class ExtendedType implements TypeDefinition { return defaultValue; } + public boolean isAddedByUses() { + return addedByUses; + } + @Override public QName getQName() { return typeName; @@ -179,124 +206,54 @@ public class ExtendedType implements TypeDefinition { } @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result - + ((baseType == null) ? 0 : baseType.hashCode()); - result = prime * result - + ((defaultValue == null) ? 0 : defaultValue.hashCode()); - result = prime * result - + ((description == null) ? 0 : description.hashCode()); - result = prime * result - + ((unknownSchemaNodes == null) ? 0 : unknownSchemaNodes.hashCode()); - result = prime * result + ((path == null) ? 0 : path.hashCode()); - result = prime * result - + ((reference == null) ? 0 : reference.hashCode()); - result = prime * result + ((status == null) ? 0 : status.hashCode()); - result = prime * result - + ((typeName == null) ? 0 : typeName.hashCode()); - result = prime * result + ((units == null) ? 0 : units.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { + public boolean equals(Object o) { + if (this == o) { return true; } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - ExtendedType other = (ExtendedType) obj; - if (baseType == null) { - if (other.baseType != null) { - return false; - } - } else if (!baseType.equals(other.baseType)) { - return false; - } - if (defaultValue == null) { - if (other.defaultValue != null) { - return false; - } - } else if (!defaultValue.equals(other.defaultValue)) { + if (!(o instanceof ExtendedType)) { return false; } - if (description == null) { - if (other.description != null) { - return false; - } - } else if (!description.equals(other.description)) { - return false; - } - if (unknownSchemaNodes == null) { - if (other.unknownSchemaNodes != null) { - return false; - } - } else if (!unknownSchemaNodes.equals(other.unknownSchemaNodes)) { - return false; - } - if (path == null) { - if (other.path != null) { - return false; - } - } else if (!path.equals(other.path)) { - return false; - } - if (reference == null) { - if (other.reference != null) { - return false; - } - } else if (!reference.equals(other.reference)) { - return false; - } - if (status != other.status) { - return false; - } - if (typeName == null) { - if (other.typeName != null) { - return false; - } - } else if (!typeName.equals(other.typeName)) { + + ExtendedType that = (ExtendedType) o; + if (path != null ? !path.equals(that.path) : that.path != null) { return false; } - if (units == null) { - if (other.units != null) { - return false; - } - } else if (!units.equals(other.units)) { + if (typeName != null ? !typeName.equals(that.typeName) : that.typeName != null) return false; - } + return true; } + @Override + public int hashCode() { + int result = typeName != null ? typeName.hashCode() : 0; + result = 31 * result + (path != null ? path.hashCode() : 0); + return result; + } + @Override public String toString() { - StringBuilder builder2 = new StringBuilder(); - builder2.append("ExtendedType [typeName="); - builder2.append(typeName); - builder2.append(", baseType="); - builder2.append(baseType); - builder2.append(", path="); - builder2.append(path); - builder2.append(", description="); - builder2.append(description); - builder2.append(", reference="); - builder2.append(reference); - builder2.append(", unknownSchemaNodes="); - builder2.append(unknownSchemaNodes); - builder2.append(", status="); - builder2.append(status); - builder2.append(", units="); - builder2.append(units); - builder2.append(", defaultValue="); - builder2.append(defaultValue); - builder2.append("]"); - return builder2.toString(); + StringBuilder builder = new StringBuilder(); + builder.append("ExtendedType [typeName="); + builder.append(typeName); + builder.append(", baseType="); + builder.append(baseType); + builder.append(", path="); + builder.append(path); + builder.append(", description="); + builder.append(description); + builder.append(", reference="); + builder.append(reference); + builder.append(", unknownSchemaNodes="); + builder.append(unknownSchemaNodes); + builder.append(", status="); + builder.append(status); + builder.append(", units="); + builder.append(units); + builder.append(", defaultValue="); + builder.append(defaultValue); + builder.append("]"); + return builder.toString(); } public List getRanges() {