Use Objects.hashCode()
[yangtools.git] / yang / yang-parser-impl / src / main / java / org / opendaylight / yangtools / yang / parser / builder / impl / AugmentationSchemaBuilderImpl.java
index 83dffd946273afa530b4bba08baeb541e866eb60..46f809b31b5b6c3583de5616d627f32a2576c3ac 100644 (file)
@@ -7,25 +7,15 @@
  */
 package org.opendaylight.yangtools.yang.parser.builder.impl;
 
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import com.google.common.base.Optional;
 import com.google.common.collect.ImmutableList;
-import java.net.URI;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.List;
-import org.opendaylight.yangtools.yang.common.QName;
+import java.util.Objects;
 import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
-import org.opendaylight.yangtools.yang.model.api.NamespaceRevisionAware;
 import org.opendaylight.yangtools.yang.model.api.RevisionAwareXPath;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
-import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
 import org.opendaylight.yangtools.yang.model.util.RevisionAwareXPathImpl;
 import org.opendaylight.yangtools.yang.parser.builder.api.AugmentationSchemaBuilder;
 import org.opendaylight.yangtools.yang.parser.builder.api.Builder;
 import org.opendaylight.yangtools.yang.parser.builder.api.UnknownSchemaNodeBuilder;
-import org.opendaylight.yangtools.yang.parser.builder.util.AbstractDocumentedDataNodeContainer;
 import org.opendaylight.yangtools.yang.parser.builder.util.AbstractDocumentedDataNodeContainerBuilder;
 
 public final class AugmentationSchemaBuilderImpl extends AbstractDocumentedDataNodeContainerBuilder implements AugmentationSchemaBuilder {
@@ -154,8 +144,8 @@ public final class AugmentationSchemaBuilderImpl extends AbstractDocumentedDataN
     public int hashCode() {
         final int prime = 17;
         int result = 1;
-        result = prime * result + ((augmentTargetStr == null) ? 0 : augmentTargetStr.hashCode());
-        result = prime * result + ((whenCondition == null) ? 0 : whenCondition.hashCode());
+        result = prime * result + Objects.hashCode(augmentTargetStr);
+        result = prime * result + Objects.hashCode(whenCondition);
         result = prime * result + getChildNodeBuilders().hashCode();
         return result;
     }
@@ -200,128 +190,4 @@ public final class AugmentationSchemaBuilderImpl extends AbstractDocumentedDataN
     public void setCopyOf(final AugmentationSchemaBuilder old) {
         copyOf = old;
     }
-
-    private static final class AugmentationSchemaImpl extends AbstractDocumentedDataNodeContainer implements AugmentationSchema, NamespaceRevisionAware, Comparable<AugmentationSchemaImpl> {
-        private final int order;
-        private final SchemaPath targetPath;
-        private RevisionAwareXPath whenCondition;
-
-        private URI namespace;
-        private Date revision;
-        private ImmutableList<UnknownSchemaNode> unknownNodes;
-        private AugmentationSchema copyOf;
-
-        public AugmentationSchemaImpl(final SchemaPath targetPath, final int order, final AugmentationSchemaBuilderImpl builder) {
-            super(builder);
-            this.targetPath = targetPath;
-            this.order = order;
-        }
-
-        public void setCopyOf(final AugmentationSchema build) {
-            this.copyOf = build;
-        }
-
-        @Override
-        public Optional<AugmentationSchema> getOriginalDefinition() {
-            return Optional.fromNullable(this.copyOf);
-        }
-
-        @Override
-        public SchemaPath getTargetPath() {
-            return targetPath;
-        }
-
-        @Override
-        public RevisionAwareXPath getWhenCondition() {
-            return whenCondition;
-        }
-
-        @Override
-        public List<UnknownSchemaNode> getUnknownSchemaNodes() {
-            return unknownNodes;
-        }
-
-        @Override
-        public URI getNamespace() {
-            return namespace;
-        }
-
-        @Override
-        public Date getRevision() {
-            return revision;
-        }
-
-        @Override
-        public int hashCode() {
-            final int prime = 17;
-            int result = 1;
-            result = prime * result + ((targetPath == null) ? 0 : targetPath.hashCode());
-            result = prime * result + ((whenCondition == null) ? 0 : whenCondition.hashCode());
-            result = prime * result + getChildNodes().hashCode();
-            return result;
-        }
-
-        @Override
-        public boolean equals(final Object obj) {
-            if (this == obj) {
-                return true;
-            }
-            if (obj == null) {
-                return false;
-            }
-            if (getClass() != obj.getClass()) {
-                return false;
-            }
-            AugmentationSchemaImpl other = (AugmentationSchemaImpl) obj;
-            if (targetPath == null) {
-                if (other.targetPath != null) {
-                    return false;
-                }
-            } else if (!targetPath.equals(other.targetPath)) {
-                return false;
-            }
-            if (whenCondition == null) {
-                if (other.whenCondition != null) {
-                    return false;
-                }
-            } else if (!whenCondition.equals(other.whenCondition)) {
-                return false;
-            }
-            if (!getChildNodes().equals(other.getChildNodes())) {
-                return false;
-            }
-            return true;
-        }
-
-        @Override
-        public String toString() {
-            StringBuilder sb = new StringBuilder(AugmentationSchemaImpl.class.getSimpleName());
-            sb.append("[");
-            sb.append("targetPath=").append(targetPath);
-            sb.append(", when=").append(whenCondition);
-            sb.append("]");
-            return sb.toString();
-        }
-
-        @Override
-        public int compareTo(final AugmentationSchemaImpl o) {
-            checkNotNull(o);
-            Iterator<QName> thisIt = this.targetPath.getPathFromRoot().iterator();
-            Iterator<QName> otherIt = o.getTargetPath().getPathFromRoot().iterator();
-            while (thisIt.hasNext()) {
-                if (otherIt.hasNext()) {
-                    int comp = thisIt.next().compareTo(otherIt.next());
-                    if (comp != 0) {
-                        return comp;
-                    }
-                } else {
-                    return 1;
-                }
-            }
-            if (otherIt.hasNext()) {
-                return -1;
-            }
-            return this.order - o.order;
-        }
-    }
 }