BUG-865: deprecate pre-Beryllium parser elements
[yangtools.git] / yang / yang-parser-impl / src / main / java / org / opendaylight / yangtools / yang / parser / builder / impl / AugmentationSchemaBuilderImpl.java
index 83dffd946273afa530b4bba08baeb541e866eb60..c2e17c9b69837d079ba67955bcc9728b6efbdf24 100644 (file)
@@ -7,27 +7,21 @@
  */
 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;
 
+/**
+ * @deprecated Pre-Beryllium implementation, scheduled for removal.
+ */
+@Deprecated
 public final class AugmentationSchemaBuilderImpl extends AbstractDocumentedDataNodeContainerBuilder implements AugmentationSchemaBuilder {
     private final int order;
     private AugmentationSchemaImpl instance;
@@ -117,7 +111,7 @@ public final class AugmentationSchemaBuilderImpl extends AbstractDocumentedDataN
      *  In such case, augmentation is skipped and AugmentationSchema is not built.
      */
     @Override
-    public void setUnsupportedTarget(boolean unsupportedTarget) {
+    public void setUnsupportedTarget(final boolean unsupportedTarget) {
         this.unsupportedTarget = unsupportedTarget;
     }
 
@@ -154,8 +148,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 +194,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;
-        }
-    }
 }