X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=yang%2Fyang-model-util%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Fyang%2Fmodel%2Futil%2FBinaryType.java;h=1e89697902cca94884191d0e29120886deffd863;hb=refs%2Fchanges%2F18%2F35918%2F2;hp=cda865d1a2fb3d7dade645513766d191793cdca9;hpb=dc09de9856ef7aff07522cbbacbdde74f4f9f3d5;p=yangtools.git diff --git a/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/BinaryType.java b/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/BinaryType.java index cda865d1a2..1e89697902 100644 --- a/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/BinaryType.java +++ b/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/BinaryType.java @@ -7,9 +7,10 @@ */ package org.opendaylight.yangtools.yang.model.util; +import com.google.common.base.Optional; import java.util.Collections; import java.util.List; - +import java.util.Objects; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.model.api.SchemaPath; import org.opendaylight.yangtools.yang.model.api.Status; @@ -21,22 +22,25 @@ import org.opendaylight.yangtools.yang.model.api.type.LengthConstraint; * The default implementation of Binary Type Definition interface. * * @see BinaryTypeDefinition + * @deprecated Use {@link org.opendaylight.yangtools.yang.model.util.type.BaseTypes#binaryType()} instead */ +@Deprecated public final class BinaryType implements BinaryTypeDefinition { private static final String DESCRIPTION = "The binary built-in type represents any binary data, i.e., a sequence of octets."; private static final String REFERENCE = "https://tools.ietf.org/html/rfc6020#section-9.8"; private static final String UNITS = ""; + private static final QName QNAME = BaseTypes.BINARY_QNAME; + private static final BinaryType INSTANCE = new BinaryType(); - private final QName name = BaseTypes.BINARY_QNAME; - private final SchemaPath path = SchemaPath.create(Collections.singletonList(name), true); + private static final SchemaPath PATH = SchemaPath.create(Collections.singletonList(QNAME), true); private final List bytes = Collections.emptyList(); private final List lengthConstraints; private BinaryType() { this.lengthConstraints = Collections.singletonList( - BaseConstraints.lengthConstraint(0, Long.MAX_VALUE, "", "")); + BaseConstraints.newLengthConstraint(0, Long.MAX_VALUE, Optional.of(""), Optional.of(""))); } public static BinaryType getInstance() { @@ -73,7 +77,7 @@ public final class BinaryType implements BinaryTypeDefinition { */ @Override public Object getDefaultValue() { - return bytes; + return null; } /* @@ -83,7 +87,7 @@ public final class BinaryType implements BinaryTypeDefinition { */ @Override public QName getQName() { - return name; + return QNAME; } /* @@ -93,7 +97,7 @@ public final class BinaryType implements BinaryTypeDefinition { */ @Override public SchemaPath getPath() { - return path; + return PATH; } /* @@ -148,10 +152,10 @@ public final class BinaryType implements BinaryTypeDefinition { public int hashCode() { final int prime = 31; int result = 1; - result = prime * result + ((bytes == null) ? 0 : bytes.hashCode()); - result = prime * result + ((lengthConstraints == null) ? 0 : lengthConstraints.hashCode()); - result = prime * result + ((name == null) ? 0 : name.hashCode()); - result = prime * result + ((path == null) ? 0 : path.hashCode()); + result = prime * result + Objects.hashCode(bytes); + result = prime * result + Objects.hashCode(lengthConstraints); + result = prime * result + QNAME.hashCode(); + result = prime * result + PATH.hashCode(); return result; } @@ -167,55 +171,23 @@ public final class BinaryType implements BinaryTypeDefinition { return false; } BinaryType other = (BinaryType) obj; - if (bytes == null) { - if (other.bytes != null) { - return false; - } - } else if (!bytes.equals(other.bytes)) { - return false; - } - if (lengthConstraints == null) { - if (other.lengthConstraints != null) { - return false; - } - } else if (!lengthConstraints.equals(other.lengthConstraints)) { - return false; - } - if (name == null) { - if (other.name != null) { - return false; - } - } else if (!name.equals(other.name)) { - return false; - } - if (path == null) { - if (other.path != null) { - return false; - } - } else if (!path.equals(other.path)) { - return false; - } - return true; + return Objects.equals(bytes, other.bytes) && Objects.equals(lengthConstraints, other.lengthConstraints); } @Override public String toString() { - StringBuilder builder = new StringBuilder(); - builder.append("BinaryType [name="); - builder.append(name); - builder.append(", path="); - builder.append(path); - builder.append(", description="); - builder.append(DESCRIPTION); - builder.append(", reference="); - builder.append(REFERENCE); - builder.append(", bytes="); - builder.append(bytes); - builder.append(", lengthConstraints="); - builder.append(lengthConstraints); - builder.append(", units="); - builder.append(UNITS); - builder.append("]"); - return builder.toString(); + return "BinaryType [name=" + + QNAME + + ", description=" + + DESCRIPTION + + ", reference=" + + REFERENCE + + ", bytes=" + + bytes + + ", lengthConstraints=" + + lengthConstraints + + ", units=" + + UNITS + + "]"; } }