io.legaldocml.akn.element.RelatedDocument Maven / Gradle / Ivy
The newest version!
package io.legaldocml.akn.element;
import com.google.common.collect.ImmutableMap;
import io.legaldocml.akn.AknObject;
import io.legaldocml.akn.attribute.LinkReq;
import io.legaldocml.akn.group.AmendmentInline;
import io.legaldocml.akn.type.Uri;
import io.legaldocml.akn.visitor.AknVisitor;
import io.legaldocml.io.AttributeGetterSetter;
import io.legaldocml.io.XmlWriter;
import io.legaldocml.io.impl.Buffers;
import java.io.IOException;
import static io.legaldocml.akn.AknAttributes.HREF;
import static io.legaldocml.akn.AknElements.RELATED_DOCUMENT;
import static io.legaldocml.akn.util.XmlWriterHelper.writeLinkReq;
import static io.legaldocml.unsafe.UnsafeHelper.getFieldOffset;
/**
* The element relatedDocument is an inline element to identify the document for which this document is a report of.
*
*
*
*
*
*
*
*
*
*
*
*
*
* @author Jacques Militello
*/
public final class RelatedDocument extends InlineType implements LinkReq, AmendmentInline {
/**
* Memory address.
*/
private static final long ADDRESS_RELATED_DOCUMENT = Buffers.address(RELATED_DOCUMENT);
private static final ImmutableMap> ATTRIBUTES;
static {
ATTRIBUTES = ImmutableMap.>builder()
.putAll(InlineType.ATTRIBUTES)
.put(HREF, Attributes.attributeGetterSetter4Uri(HREF, getFieldOffset(RelatedDocument.class, "href")))
.build();
}
private Uri href;
/**
* {@inheritDoc}
*/
@Override
public Uri getHref() {
return this.href;
}
/**
* {@inheritDoc}
*/
@Override
public void setHref(Uri href) {
this.href = href;
}
/**
* {@inheritDoc}
*/
@Override
public void write(XmlWriter writer) throws IOException {
writer.writeStart(ADDRESS_RELATED_DOCUMENT, 15);
writeLinkReq(writer, this);
super.write(writer);
writer.writeEnd(ADDRESS_RELATED_DOCUMENT, 15);
}
/**
* {@inheritDoc}
*/
@Override
public String name() {
return RELATED_DOCUMENT;
}
/**
* {@inheritDoc}
*/
@Override
public ImmutableMap> attributes() {
return ATTRIBUTES;
}
/**
* {@inheritDoc}
*/
@Override
public void accept(AknVisitor visitor) {
if (visitor.visitEnter(this)) {
super.accept(visitor);
visitor.visitLeave(this);
}
}
}