-
- private static final class AugmentationSchemaImpl extends AbstractDocumentedDataNodeContainer implements AugmentationSchema, NamespaceRevisionAware, Comparable<AugmentationSchemaImpl> {
- private final int order;
- private 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;
- }
- }