- private final class AugmentationSchemaImpl implements AugmentationSchema {
- private SchemaPath targetPath;
- private RevisionAwareXPath whenCondition;
- private Map<QName, DataSchemaNode> childNodes = Collections.emptyMap();
- private Set<UsesNode> uses = Collections.emptySet();
- private String description;
- private String reference;
- private Status status;
- private List<UnknownSchemaNode> unknownNodes = Collections.emptyList();
-
- private AugmentationSchemaImpl(SchemaPath targetPath) {
- this.targetPath = targetPath;
- }
-
- @Override
- public SchemaPath getTargetPath() {
- return targetPath;
- }
-
- private void setTargetPath(SchemaPath path) {
- this.targetPath = path;
- }
-
- @Override
- public RevisionAwareXPath getWhenCondition() {
- return whenCondition;
- }
-
- private void setWhenCondition(RevisionAwareXPath whenCondition) {
- this.whenCondition = whenCondition;
- }
-
- @Override
- public Set<DataSchemaNode> getChildNodes() {
- final Set<DataSchemaNode> result = new TreeSet<DataSchemaNode>(Comparators.SCHEMA_NODE_COMP);
- result.addAll(childNodes.values());
- return result;
- }
-
- private void setChildNodes(Map<QName, DataSchemaNode> childNodes) {
- if (childNodes != null) {
- this.childNodes = childNodes;
- }
- }
-
- /**
- * Always returns an empty set, because augment can not contains
- * grouping statement.
- */
- @Override
- public Set<GroupingDefinition> getGroupings() {
- return Collections.emptySet();
- }
-
- @Override
- public Set<UsesNode> getUses() {
- return uses;
- }
-
- private void setUses(Set<UsesNode> uses) {
- if (uses != null) {
- this.uses = uses;
- }
- }
-
- /**
- * Always returns an empty set, because augment can not contains type
- * definitions.
- */
- @Override
- public Set<TypeDefinition<?>> getTypeDefinitions() {
- return Collections.emptySet();
- }
-
- @Override
- public String getDescription() {
- return description;
- }
-
- private void setDescription(String description) {
- this.description = description;
- }
-
- @Override
- public String getReference() {
- return reference;
- }
-
- private void setReference(String reference) {
- this.reference = reference;
- }
-
- @Override
- public Status getStatus() {
- return status;
- }
-
- private void setStatus(Status status) {
- this.status = status;
- }
-
- @Override
- public List<UnknownSchemaNode> getUnknownSchemaNodes() {
- return unknownNodes;
- }
-
- private void setUnknownSchemaNodes(List<UnknownSchemaNode> unknownSchemaNodes) {
- if (unknownSchemaNodes != null) {
- this.unknownNodes = unknownSchemaNodes;
- }
- }
-
- @Override
- public DataSchemaNode getDataChildByName(QName name) {
- return childNodes.get(name);
- }
-
- @Override
- public DataSchemaNode getDataChildByName(String name) {
- DataSchemaNode result = null;
- for (Map.Entry<QName, DataSchemaNode> entry : childNodes.entrySet()) {
- if (entry.getKey().getLocalName().equals(name)) {
- result = entry.getValue();
- break;
- }
- }
- return result;
- }
-
- @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 + ((childNodes == null) ? 0 : childNodes.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(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 (childNodes == null) {
- if (other.childNodes != null) {
- return false;
- }
- } else if (!childNodes.equals(other.childNodes)) {
- return false;
- }
- return true;
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder(AugmentationSchemaImpl.class.getSimpleName());
- sb.append("[");
- sb.append("targetPath=" + targetPath);
- sb.append(", when=" + whenCondition);
- sb.append("]");
- return sb.toString();
- }