io.legaldocml.akn.element.AttachmentsV2 Maven / Gradle / Ivy
The newest version!
package io.legaldocml.akn.element;
import com.google.common.collect.ImmutableMap;
import io.legaldocml.akn.attribute.CoreOpt;
import io.legaldocml.akn.util.AknList;
import io.legaldocml.akn.util.XmlReaderHelper;
import io.legaldocml.io.impl.Buffers;
import io.legaldocml.io.XmlReader;
import io.legaldocml.io.XmlWriter;
import java.io.IOException;
import java.util.function.Supplier;
import static io.legaldocml.akn.AknElements.ATTACHMENTS;
import static io.legaldocml.akn.AknElements.COMPONENT_REF;
/**
*
*
*
*
*
*
*
*
*
*
*
*
* @author Jacques Militello
*/
public final class AttachmentsV2 extends AbstractCore implements CoreOpt, Attachments{
/**
* Memory address.
*/
private static final long ADDRESS_ATTACHMENTS = Buffers.address(ATTACHMENTS);
private static final ImmutableMap> ELEMS;
static {
ELEMS = ImmutableMap.of(COMPONENT_REF, ComponentRef::new);
}
// Mandatory (min 1).
private final AknList elements = new AknList<>(new ComponentRef[4]);
/**
* {@inheritDoc}
*/
@Override
public void write(XmlWriter writer) throws IOException {
writer.writeStart(ADDRESS_ATTACHMENTS, 11);
CoreOpt.super.write(writer);
this.elements.write(writer);
writer.writeEnd(ADDRESS_ATTACHMENTS, 11);
}
/**
* {@inheritDoc}
*/
@Override
public void read(XmlReader reader) {
super.read(reader);
XmlReaderHelper.read(reader, this.elements, ELEMS);
}
}