public final class UnknownSchemaNodeBuilder extends AbstractSchemaNodeBuilder {
private boolean isBuilt;
private final UnknownSchemaNodeImpl instance;
- private boolean addedByUses;
private QName nodeType;
private String nodeParameter;
private ExtensionDefinition extensionDefinition;
private ExtensionBuilder extensionBuilder;
- public UnknownSchemaNodeBuilder(final String moduleName, final int line, final QName qname) {
+ public UnknownSchemaNodeBuilder(final String moduleName, final int line, final QName qname, final SchemaPath path) {
super(moduleName, line, qname);
- instance = new UnknownSchemaNodeImpl(qname);
+ this.schemaPath = path;
+ instance = new UnknownSchemaNodeImpl(qname, path);
+ }
+
+ public UnknownSchemaNodeBuilder(final String moduleName, final int line, final QName qname, final SchemaPath path, final UnknownSchemaNode base) {
+ super(moduleName, line, base.getQName());
+ this.schemaPath = path;
+ instance = new UnknownSchemaNodeImpl(qname, path);
+
+ instance.nodeType = base.getNodeType();
+ instance.nodeParameter = base.getNodeParameter();
+ instance.description = base.getDescription();
+ instance.reference = base.getReference();
+ instance.status = base.getStatus();
+ instance.addedByUses = base.isAddedByUses();
+ instance.extension = base.getExtensionDefinition();
+ instance.unknownNodes.addAll(base.getUnknownSchemaNodes());
+ }
+
+ @Override
+ public SchemaPath getPath() {
+ return instance.path;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((qname == null) ? 0 : qname.hashCode());
+ result = prime * result + ((schemaPath == null) ? 0 : schemaPath.hashCode());
+ result = prime * result + ((nodeType == null) ? 0 : nodeType.hashCode());
+ result = prime * result + ((nodeParameter == null) ? 0 : nodeParameter.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;
+ }
+ UnknownSchemaNodeBuilder other = (UnknownSchemaNodeBuilder) obj;
+ if (qname == null) {
+ if (other.qname != null) {
+ return false;
+ }
+ } else if (!qname.equals(other.qname)) {
+ return false;
+ }
+ if (schemaPath == null) {
+ if (other.schemaPath != null) {
+ return false;
+ }
+ } else if (!schemaPath.equals(other.schemaPath)) {
+ return false;
+ }
+ if (nodeType == null) {
+ if (other.nodeType != null) {
+ return false;
+ }
+ } else if (!nodeType.equals(other.nodeType)) {
+ return false;
+ }
+ if (nodeParameter == null) {
+ if (other.nodeParameter != null) {
+ return false;
+ }
+ } else if (!nodeParameter.equals(other.nodeParameter)) {
+ return false;
+ }
+ return true;
}
@Override
public UnknownSchemaNode build() {
if (!isBuilt) {
- instance.setPath(schemaPath);
instance.setNodeType(nodeType);
instance.setNodeParameter(nodeParameter);
- instance.setDescription(description);
- instance.setReference(reference);
- instance.setStatus(status);
- instance.setAddedByUses(addedByUses);
// EXTENSION
if (extensionDefinition != null) {
}
// UNKNOWN NODES
- if (unknownNodes == null) {
- unknownNodes = new ArrayList<UnknownSchemaNode>();
- for (UnknownSchemaNodeBuilder b : addedUnknownNodes) {
- unknownNodes.add(b.build());
- }
- Collections.sort(unknownNodes, Comparators.SCHEMA_NODE_COMP);
+ for (UnknownSchemaNodeBuilder b : addedUnknownNodes) {
+ unknownNodes.add(b.build());
}
+ Collections.sort(unknownNodes, Comparators.SCHEMA_NODE_COMP);
instance.setUnknownSchemaNodes(unknownNodes);
isBuilt = true;
return instance;
}
- public void setQName(QName qname) {
- this.qname = qname;
+ @Override
+ public String getDescription() {
+ return instance.description;
+ }
+
+ @Override
+ public void setDescription(final String description) {
+ instance.description = description;
+ }
+
+ @Override
+ public String getReference() {
+ return instance.reference;
+ }
+
+ @Override
+ public void setReference(final String reference) {
+ instance.reference = reference;
+ }
+
+ @Override
+ public Status getStatus() {
+ return instance.status;
+ }
+
+ @Override
+ public void setStatus(Status status) {
+ if (status != null) {
+ instance.status = status;
+ }
}
public boolean isAddedByUses() {
- return addedByUses;
+ return instance.addedByUses;
}
public void setAddedByUses(final boolean addedByUses) {
- this.addedByUses = addedByUses;
+ instance.addedByUses = addedByUses;
}
public QName getNodeType() {
return sb.toString();
}
- private final class UnknownSchemaNodeImpl implements UnknownSchemaNode {
+ private static final class UnknownSchemaNodeImpl implements UnknownSchemaNode {
private final QName qname;
- private SchemaPath path;
+ private final SchemaPath path;
private ExtensionDefinition extension;
private String description;
private String reference;
private Status status = Status.CURRENT;
- private List<UnknownSchemaNode> unknownNodes = Collections.emptyList();
+ private final List<UnknownSchemaNode> unknownNodes = new ArrayList<>();
private QName nodeType;
private String nodeParameter;
private boolean addedByUses;
- private UnknownSchemaNodeImpl(final QName qname) {
+ private UnknownSchemaNodeImpl(final QName qname, final SchemaPath path) {
this.qname = qname;
+ this.path = path;
}
@Override
return path;
}
- private void setPath(final SchemaPath path) {
- this.path = path;
- }
-
@Override
public ExtensionDefinition getExtensionDefinition() {
return extension;
return description;
}
- private void setDescription(final String description) {
- this.description = description;
- }
-
@Override
public String getReference() {
return reference;
}
- private void setReference(final String reference) {
- this.reference = reference;
- }
-
@Override
public Status getStatus() {
return status;
}
- private void setStatus(final Status status) {
- if (status != null) {
- this.status = status;
- }
- }
-
@Override
public boolean isAddedByUses() {
return addedByUses;
}
- private void setAddedByUses(final boolean addedByUses) {
- this.addedByUses = addedByUses;
- }
-
@Override
public List<UnknownSchemaNode> getUnknownSchemaNodes() {
return unknownNodes;
private void setUnknownSchemaNodes(final List<UnknownSchemaNode> unknownNodes) {
if (unknownNodes != null) {
- this.unknownNodes = unknownNodes;
+ this.unknownNodes.addAll(unknownNodes);
}
}
sb.append(nodeParameter);
return sb.toString();
}
+
+ @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());
+ result = prime * result + ((nodeType == null) ? 0 : nodeType.hashCode());
+ result = prime * result + ((nodeParameter == null) ? 0 : nodeParameter.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;
+ }
+ UnknownSchemaNodeImpl other = (UnknownSchemaNodeImpl) 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;
+ }
+ if (nodeType == null) {
+ if (other.nodeType != null) {
+ return false;
+ }
+ } else if (!nodeType.equals(other.nodeType)) {
+ return false;
+ }
+ if (nodeParameter == null) {
+ if (other.nodeParameter != null) {
+ return false;
+ }
+ } else if (!nodeParameter.equals(other.nodeParameter)) {
+ return false;
+ }
+ return true;
+ }
+
}
}