-/**
+/*
* Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
private final boolean addedByUses;
private final ConstraintDefinition constraints;
private final List<UnknownSchemaNode> unknownNodes;
+ private final ChoiceCaseNode original;
public CaseShorthandImpl(final DataSchemaNode caseShorthandNode) {
this.caseShorthandNode = caseShorthandNode;
this.addedByUses = caseShorthandNode.isAddedByUses();
this.constraints = caseShorthandNode.getConstraints();
this.unknownNodes = ImmutableList.copyOf(caseShorthandNode.getUnknownSchemaNodes());
+
+ this.original = getOriginalIfPresent(caseShorthandNode);
}
@Override
@Override
public Optional<? extends SchemaNode> getOriginal() {
- return Optional.absent();
+ return Optional.fromNullable(original);
}
@Override
sb.append("]");
return sb.toString();
}
+
+ private static ChoiceCaseNode getOriginalIfPresent(final SchemaNode caseShorthandNode) {
+ if (caseShorthandNode instanceof DerivableSchemaNode) {
+ final Optional<? extends SchemaNode> original = ((DerivableSchemaNode) caseShorthandNode).getOriginal();
+ if (original.isPresent()) {
+ return new CaseShorthandImpl((DataSchemaNode) original.get());
+ }
+ }
+ return null;
+ }
}