com.thaiopensource.relaxng.output.xsd.basic.OptionalAttribute Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of trang Show documentation
Show all versions of trang Show documentation
Jing/Trang - tools for validating and translating RelaxNG
The 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;
}
}