All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.thaiopensource.relaxng.output.xsd.basic.OptionalAttribute Maven / Gradle / Ivy

There is a newer version: 20220510
Show newest version
package com.thaiopensource.relaxng.output.xsd.basic;

import com.thaiopensource.relaxng.edit.SourceLocation;
import com.thaiopensource.xml.util.Name;
import com.thaiopensource.util.Equal;

public class OptionalAttribute extends SingleAttributeUse {
  private final Attribute attribute;
  private final String defaultValue;

  public OptionalAttribute(SourceLocation location, Annotation annotation, Attribute attribute, String defaultValue) {
    super(location, annotation);
    this.attribute = attribute;
    this.defaultValue = defaultValue;
  }

  public Attribute getAttribute() {
    return attribute;
  }

  public  T accept(AttributeUseVisitor visitor) {
    return visitor.visitOptionalAttribute(this);
  }

  public Name getName() {
    return attribute.getName();
  }

  public SimpleType getType() {
    return attribute.getType();
  }

  public String getDefaultValue() {
    return defaultValue;
  }

  public boolean isOptional() {
    return true;
  }

  public boolean equals(Object obj) {
    return (super.equals(obj)
            && ((OptionalAttribute)obj).attribute.equals(attribute)
            && Equal.equal(defaultValue, ((OptionalAttribute)obj).defaultValue));
  }

  public int hashCode() {
    int hc = super.hashCode() ^ attribute.hashCode();
    if (defaultValue != null)
      hc ^= defaultValue.hashCode();
    return hc;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy