BUG 1131: untangling package cyclic dependencies in yang-parser-impl
[yangtools.git] / yang / yang-model-util / src / main / java / org / opendaylight / yangtools / yang / model / util / BitImpl.java
similarity index 80%
rename from yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/util/BitImpl.java
rename to yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/BitImpl.java
index 635e57e0679a836ab9d11c0770e6a83603ad8f19..92f94f27ffc629ce30907d39c3469b7946599ebb 100644 (file)
@@ -5,7 +5,7 @@
  * 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.yangtools.yang.parser.util;
+package org.opendaylight.yangtools.yang.model.util;
 
 import java.util.Collections;
 import java.util.List;
@@ -18,7 +18,9 @@ import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition.Bit;
 
-final class BitImpl implements BitsTypeDefinition.Bit, Immutable {
+import com.google.common.base.Preconditions;
+
+public final class BitImpl implements BitsTypeDefinition.Bit, Immutable {
     private final Long position;
     private final QName qname;
     private final SchemaPath schemaPath;
@@ -27,11 +29,11 @@ final class BitImpl implements BitsTypeDefinition.Bit, Immutable {
     private final Status status;
     private List<UnknownSchemaNode> unknownNodes = Collections.emptyList();
 
-    BitImpl(final Long position, final QName qname, final SchemaPath schemaPath, final String description,
+    public BitImpl(final Long position, final QName qname, final SchemaPath schemaPath, final String description,
             final String reference, final Status status, final List<UnknownSchemaNode> unknownNodes) {
-        this.position = position;
-        this.qname = qname;
-        this.schemaPath = schemaPath;
+        this.position = Preconditions.checkNotNull(position, "Position should not be null");
+        this.qname = Preconditions.checkNotNull(qname, "QName should not be null");
+        this.schemaPath = Preconditions.checkNotNull(schemaPath, "Schema Path should not be null");
         this.description = description;
         this.reference = reference;
         this.status = status;
@@ -84,15 +86,15 @@ final class BitImpl implements BitsTypeDefinition.Bit, Immutable {
     public int hashCode() {
         final int prime = 31;
         int result = 1;
-        result = prime * result + ((qname == null) ? 0 : qname.hashCode());
-        result = prime * result + ((schemaPath == null) ? 0 : schemaPath.hashCode());
-        result = prime * result + ((position == null) ? 0 : position.hashCode());
+        result = prime * result + qname.hashCode();
+        result = prime * result + schemaPath.hashCode();
+        result = prime * result + position.hashCode();
         result = prime * result + ((unknownNodes == null) ? 0 : unknownNodes.hashCode());
         return result;
     }
 
     @Override
-    public boolean equals(Object obj) {
+    public boolean equals(final Object obj) {
         if (this == obj) {
             return true;
         }