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

io.legaldocml.akn.element.Basicopt 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.container.BlockElementsContainer;
import io.legaldocml.akn.group.ANblock;
import io.legaldocml.akn.group.BlockElements;
import io.legaldocml.akn.group.HTMLblock;
import io.legaldocml.akn.util.AknList;
import io.legaldocml.akn.util.XmlReaderHelper;
import io.legaldocml.akn.visitor.AknVisitor;
import io.legaldocml.io.XmlReader;
import io.legaldocml.io.XmlWriter;

import java.io.IOException;
import java.util.function.Supplier;

import static io.legaldocml.akn.element.Groups.basicContainers;
import static io.legaldocml.akn.element.Groups.blockElements;
import static io.legaldocml.akn.element.Groups.convertSuper;
import static java.util.Objects.requireNonNull;

/**
 * the complex type basicopt defines the content model and attributes used by basic containers such as coverPage and
 * conclusions. Here the eId attribute is optional
 * 

*

 *   
 * 	   
 * 	     
 * 		 
 * 	   
 *     
 *   
 * 
* * @author Jacques Militello */ public abstract class Basicopt extends AbstractCore implements CoreOpt, BlockElementsContainer { private static final ImmutableMap> ELEMS; static { ELEMS = ImmutableMap.>builder() .putAll(convertSuper(blockElements())) .putAll(convertSuper(basicContainers())) .build(); } // Mandatory (min 1). private final AknList elements = new AknList<>(new BasicoptElement[8]); public final void addBasicoptElement(BasicoptElement element) { this.elements.add(requireNonNull(element)); } public final boolean removeBasicoptElement(BasicoptElement element) { return this.elements.remove(requireNonNull(element)); } /** * {@inheritDoc} */ @Override public final BasicoptElement remove(int index) { return this.elements.remove(index); } /** * {@inheritDoc} */ @Override public void add(BlockElements elements) { addBasicoptElement(elements); } /** * {@inheritDoc} */ @Override public void add(HTMLblock block) { addBasicoptElement(block); } /** * {@inheritDoc} */ @Override public void add(ANblock block) { addBasicoptElement(block); } /** * {@inheritDoc} */ @Override public boolean remove(ANblock block) { return removeBasicoptElement(block); } /** * {@inheritDoc} */ @Override public void read(XmlReader reader) { super.read(reader); XmlReaderHelper.read(reader, this.elements, ELEMS); } /** * {@inheritDoc} */ @Override public void write(XmlWriter writer) throws IOException { CoreOpt.super.write(writer); this.elements.write(writer); } /** * {@inheritDoc} */ @Override public void accept(AknVisitor visitor) { this.elements.accept(visitor); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy