package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Iterables;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
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;
+ private final ConstraintDefinition constraints;
+ private final List<UnknownSchemaNode> unknownNodes;
- public CaseShorthandImpl(DataSchemaNode caseShorthandNode) {
+ public CaseShorthandImpl(final DataSchemaNode caseShorthandNode) {
this.caseShorthandNode = caseShorthandNode;
this.qName = caseShorthandNode.getQName();
-
- SchemaPath caseShorthandNodePath = caseShorthandNode.getPath();
- Iterable<QName> pathFromRoot = caseShorthandNodePath.getPathFromRoot();
- this.path = SchemaPath
- .create(Iterables.limit(pathFromRoot,
- Iterables.size(pathFromRoot) - 1),
- caseShorthandNodePath.isAbsolute());
-
+ this.path = Preconditions.checkNotNull(caseShorthandNode.getPath().getParent());
this.description = caseShorthandNode.getDescription();
this.reference = caseShorthandNode.getReference();
this.status = caseShorthandNode.getStatus();
}
@Override
- public DataSchemaNode getDataChildByName(QName name) {
+ public DataSchemaNode getDataChildByName(final QName name) {
if (qName.equals(name)) {
return caseShorthandNode;
} else {
}
@Override
- public DataSchemaNode getDataChildByName(String name) {
+ public DataSchemaNode getDataChildByName(final String name) {
if (qName.getLocalName().equals(name)) {
return caseShorthandNode;
} else {
@Override
public Optional<? extends SchemaNode> getOriginal() {
- return Optional.fromNullable(original);
+ return Optional.absent();
}
@Override
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;
+ return Objects.equals(qName, other.qName) && Objects.equals(path, other.path);
}
@Override
public String toString() {
- StringBuilder sb = new StringBuilder(
- CaseShorthandImpl.class.getSimpleName());
+ StringBuilder sb = new StringBuilder(CaseShorthandImpl.class.getSimpleName());
sb.append("[");
sb.append("qname=");
sb.append(qName);
sb.append("]");
return sb.toString();
}
-
}