*/
package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+import com.google.common.collect.ImmutableList;
+import com.google.common.base.Optional;
+import org.opendaylight.yangtools.yang.model.api.SchemaNode;
+import org.opendaylight.yangtools.yang.model.api.DerivableSchemaNode;
import com.google.common.collect.Iterables;
import java.util.Collections;
import java.util.Arrays;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
-public class CaseShorthandImpl implements ChoiceCaseNode {
+public class CaseShorthandImpl implements ChoiceCaseNode, DerivableSchemaNode {
private final DataSchemaNode caseShorthandNode;
private final QName qName;
private final SchemaPath path;
+ private final String description;
+ private final String reference;
+ private final Status status;
+
+ private final boolean augmenting;
+ private final boolean addedByUses;
+ ConstraintDefinition constraints;
+ private ChoiceCaseNode original;
+
+ ImmutableList<UnknownSchemaNode> unknownNodes;
+
public CaseShorthandImpl(DataSchemaNode caseShorthandNode) {
this.caseShorthandNode = caseShorthandNode;
this.qName = caseShorthandNode.getQName();
.create(Iterables.limit(pathFromRoot,
Iterables.size(pathFromRoot) - 1),
caseShorthandNodePath.isAbsolute());
+
+ this.description = caseShorthandNode.getDescription();
+ this.reference = caseShorthandNode.getReference();
+ this.status = caseShorthandNode.getStatus();
+
+ this.augmenting = caseShorthandNode.isAugmenting();
+ this.addedByUses = caseShorthandNode.isAddedByUses();
+ this.constraints = caseShorthandNode.getConstraints();
+ this.unknownNodes = ImmutableList.copyOf(caseShorthandNode.getUnknownSchemaNodes());
}
@Override
public boolean isAugmenting() {
- return caseShorthandNode.isAugmenting();
+ return augmenting;
}
@Override
public boolean isAddedByUses() {
- return caseShorthandNode.isAddedByUses();
+ return addedByUses;
}
@Override
public boolean isConfiguration() {
- return caseShorthandNode.isConfiguration();
+ return false;
}
@Override
public ConstraintDefinition getConstraints() {
- return caseShorthandNode.getConstraints();
+ return constraints;
}
@Override
public QName getQName() {
- return caseShorthandNode.getQName();
+ return qName;
}
@Override
@Override
public List<UnknownSchemaNode> getUnknownSchemaNodes() {
- return caseShorthandNode.getUnknownSchemaNodes();
+ return unknownNodes;
}
@Override
public String getDescription() {
- return caseShorthandNode.getDescription();
+ return description;
}
@Override
public String getReference() {
- return caseShorthandNode.getReference();
+ return reference;
}
@Override
public Status getStatus() {
- return caseShorthandNode.getStatus();
+ return status;
}
@Override
public Set<AugmentationSchema> getAvailableAugmentations() {
return Collections.emptySet();
}
+
+ @Override
+ public Optional<? extends SchemaNode> getOriginal() {
+ return Optional.fromNullable(original);
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((qName == null) ? 0 : qName.hashCode());
+ result = prime * result + ((path == null) ? 0 : path.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;
+ }
+ CaseShorthandImpl other = (CaseShorthandImpl) obj;
+ if (qName == null) {
+ if (other.qName != null) {
+ return false;
+ }
+ } else if (!qName.equals(other.qName)) {
+ return false;
+ }
+ if (path == null) {
+ if (other.path != null) {
+ return false;
+ }
+ } else if (!path.equals(other.path)) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder(
+ CaseShorthandImpl.class.getSimpleName());
+ sb.append("[");
+ sb.append("qname=");
+ sb.append(qName);
+ sb.append("]");
+ return sb.toString();
+ }
+
}
\ No newline at end of file