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=89a78d261470e8ea107702e27f40e9db52cec818;hb=1bdc29c20e850029a42dd64ece95f0a4330db611;hp=de7a3058ea437413e48ef2bc082551a9d2abd387;hpb=c173dce5639bef5016b14debdef051e79ebe91f1;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 de7a3058ea..89a78d2614 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 @@ -24,33 +24,24 @@ import org.opendaylight.yangtools.yang.model.api.type.LengthConstraint; * @see BinaryTypeDefinition */ public final class BinaryType implements BinaryTypeDefinition { + private static final BinaryType INSTANCE = new BinaryType(); private final QName name = BaseTypes.constructQName("binary"); - private final SchemaPath path; + private final SchemaPath path = new SchemaPath(Collections.singletonList(name), true); private final String description = "The binary built-in type represents any binary data, i.e., a sequence of octets."; private final String reference = "https://tools.ietf.org/html/rfc6020#section-9.8"; - private final BinaryTypeDefinition baseType; private final List bytes; private final List lengthConstraints; private final String units = ""; - public BinaryType(final SchemaPath path) { + private BinaryType() { final List constraints = new ArrayList(); - constraints.add(BaseConstraints.lengthConstraint(0, Long.MAX_VALUE, "", - "")); + constraints.add(BaseConstraints.lengthConstraint(0, Long.MAX_VALUE, "", "")); this.lengthConstraints = Collections.unmodifiableList(constraints); this.bytes = Collections.emptyList(); - this.path = path; - this.baseType = this; } - public BinaryType(final SchemaPath path, final List bytes) { - final List constraints = new ArrayList(); - constraints.add(BaseConstraints.lengthConstraint(0, Long.MAX_VALUE, "", - "")); - this.lengthConstraints = Collections.unmodifiableList(constraints); - this.bytes = Collections.unmodifiableList(bytes); - this.path = path; - this.baseType = this; + public static BinaryType getInstance() { + return INSTANCE; } /* @@ -61,7 +52,7 @@ public final class BinaryType implements BinaryTypeDefinition { */ @Override public BinaryTypeDefinition getBaseType() { - return baseType; + return this; } /* @@ -159,16 +150,11 @@ public final class BinaryType implements BinaryTypeDefinition { final int prime = 31; int result = 1; result = prime * result + ((bytes == null) ? 0 : bytes.hashCode()); - result = prime * result - + ((description == null) ? 0 : description.hashCode()); - result = prime - * result - + ((lengthConstraints == null) ? 0 : lengthConstraints - .hashCode()); + result = prime * result + ((description == null) ? 0 : description.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 - + ((reference == null) ? 0 : reference.hashCode()); + result = prime * result + ((reference == null) ? 0 : reference.hashCode()); result = prime * result + ((units == null) ? 0 : units.hashCode()); return result; }