- public final class ChoiceNodeImpl implements ChoiceNode {
- private final QName qname;
- private SchemaPath path;
- private String description;
- private String reference;
- private Status status = Status.CURRENT;
- private boolean augmenting;
- private boolean addedByUses;
- private boolean configuration;
- private ConstraintDefinition constraints;
- private Set<ChoiceCaseNode> cases = Collections.emptySet();
- private Set<AugmentationSchema> augmentations = Collections.emptySet();
- private List<UnknownSchemaNode> unknownNodes = Collections.emptyList();
- private String defaultCase;
-
- private ChoiceNodeImpl(QName qname) {
- this.qname = qname;
- }
-
- @Override
- public QName getQName() {
- return qname;
- }
-
- @Override
- public SchemaPath getPath() {
- return path;
- }
-
- private void setPath(SchemaPath path) {
- this.path = path;
- }
-
- @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) {
- if (status != null) {
- this.status = status;
- }
- }
-
- @Override
- public boolean isAugmenting() {
- return augmenting;
- }
-
- private void setAugmenting(boolean augmenting) {
- this.augmenting = augmenting;
- }
-
- @Override
- public boolean isAddedByUses() {
- return addedByUses;
- }
-
- private void setAddedByUses(boolean addedByUses) {
- this.addedByUses = addedByUses;
- }
-
- @Override
- public boolean isConfiguration() {
- return configuration;
- }
-
- private void setConfiguration(boolean configuration) {
- this.configuration = configuration;
- }
-
- @Override
- public ConstraintDefinition getConstraints() {
- return constraints;
- }
-
- private void setConstraints(ConstraintDefinition constraints) {
- this.constraints = constraints;
- }
-
- @Override
- public Set<AugmentationSchema> getAvailableAugmentations() {
- return augmentations;
- }
-
- private void setAvailableAugmentations(Set<AugmentationSchema> availableAugmentations) {
- if (availableAugmentations != null) {
- this.augmentations = availableAugmentations;
- }
- }
-
- @Override
- public List<UnknownSchemaNode> getUnknownSchemaNodes() {
- return unknownNodes;
- }
-
- private void setUnknownSchemaNodes(List<UnknownSchemaNode> unknownSchemaNodes) {
- if (unknownSchemaNodes != null) {
- this.unknownNodes = unknownSchemaNodes;
- }
- }
-
- @Override
- public Set<ChoiceCaseNode> getCases() {
- return cases;
- }
-
- @Override
- public ChoiceCaseNode getCaseNodeByName(final QName name) {
- if (name == null) {
- throw new IllegalArgumentException("Choice Case QName cannot be NULL!");
- }
- for (final ChoiceCaseNode caseNode : cases) {
- if (caseNode != null && name.equals(caseNode.getQName())) {
- return caseNode;
- }
- }
- return null;
- }
-
- @Override
- public ChoiceCaseNode getCaseNodeByName(final String name) {
- if (name == null) {
- throw new IllegalArgumentException("Choice Case string Name cannot be NULL!");
- }
- for (final ChoiceCaseNode caseNode : cases) {
- if (caseNode != null && (caseNode.getQName() != null)
- && name.equals(caseNode.getQName().getLocalName())) {
- return caseNode;
- }
- }
- return null;
- }
-
- private void setCases(Set<ChoiceCaseNode> cases) {
- if (cases != null) {
- this.cases = cases;
- }
- }
-
- @Override
- public String getDefaultCase() {
- return defaultCase;
- }
-
- private void setDefaultCase(String defaultCase) {
- this.defaultCase = defaultCase;
- }
-
- public ChoiceBuilder toBuilder() {
- return ChoiceBuilder.this;
- }
-
- @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(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- ChoiceNodeImpl other = (ChoiceNodeImpl) 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(ChoiceNodeImpl.class.getSimpleName());
- sb.append("[");
- sb.append("qname=" + qname);
- sb.append("]");
- return sb.toString();
- }
- }
-