io.legaldocml.akn.element.Ref 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.ANinline;
import io.legaldocml.akn.type.Uri;
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.REF;
import static io.legaldocml.akn.util.XmlWriterHelper.writeLinkReq;
import static io.legaldocml.unsafe.UnsafeHelper.getFieldOffset;
/**
* The element ref is an inline element containing a legal reference.
*
*
*
*
*
*
*
*
*
*
*
*
*
* @author Jacques Militello
*/
public final class Ref extends InlineReqType implements ANinline, LinkReq {
/**
* Memory address.
*/
private static final long ADDRESS_REF = Buffers.address(REF);
private static final ImmutableMap> ATTRIBUTES;
static {
ATTRIBUTES = ImmutableMap.>builder()
.putAll(InlineReqType.ATTRIBUTES)
.put(HREF, Attributes.attributeGetterSetter4Uri(HREF, getFieldOffset(Ref.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_REF, 3);
writeLinkReq(writer, this);
super.write(writer);
writer.writeEnd(ADDRESS_REF, 3);
}
/**
* {@inheritDoc}
*/
@Override
public String name() {
return REF;
}
/**
* {@inheritDoc}
*/
@Override
public ImmutableMap> attributes() {
return ATTRIBUTES;
}
}