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

io.legaldocml.akn.element.Groups Maven / Gradle / Ivy

The newest version!
package io.legaldocml.akn.element;

import com.google.common.collect.ImmutableMap;
import io.legaldocml.akn.AknElements;
import io.legaldocml.akn.AkomaNtosoContext;
import io.legaldocml.akn.DocumentType;
import io.legaldocml.akn.group.ANblock;
import io.legaldocml.akn.group.ANcontainers;
import io.legaldocml.akn.group.ANheaderInline;
import io.legaldocml.akn.group.ANhier;
import io.legaldocml.akn.group.ANinline;
import io.legaldocml.akn.group.ANmarker;
import io.legaldocml.akn.group.ANsemanticInline;
import io.legaldocml.akn.group.ANsubFlow;
import io.legaldocml.akn.group.ANtitleInline;
import io.legaldocml.akn.group.AmendmentInline;
import io.legaldocml.akn.group.BasicContainers;
import io.legaldocml.akn.group.BlockElements;
import io.legaldocml.akn.group.ContainerElements;
import io.legaldocml.akn.group.DocRef;
import io.legaldocml.akn.group.HTMLMarker;
import io.legaldocml.akn.group.HTMLblock;
import io.legaldocml.akn.group.HTMLcontainers;
import io.legaldocml.akn.group.HTMLinline;
import io.legaldocml.akn.group.HierElements;
import io.legaldocml.akn.group.InlineCM;
import io.legaldocml.akn.group.InlineElements;
import io.legaldocml.akn.group.MarkerElements;
import io.legaldocml.akn.group.PreambleContainers;
import io.legaldocml.akn.group.PrefaceContainers;
import io.legaldocml.akn.group.SpeechSection;
import io.legaldocml.akn.group.SubFlowElements;
import io.legaldocml.akn.group.TLC;
import io.legaldocml.io.XmlReader;

import java.util.Map;
import java.util.function.Supplier;

import static io.legaldocml.akn.AknElements.*;
import static io.legaldocml.akn.AknElements.ACT;
import static io.legaldocml.akn.AknElements.AMENDMENT;
import static io.legaldocml.akn.AknElements.AMENDMENT_LIST;
import static io.legaldocml.akn.AknElements.BILL;
import static io.legaldocml.akn.AknElements.BLOCK;
import static io.legaldocml.akn.AknElements.BLOCK_CONTAINER;
import static io.legaldocml.akn.AknElements.BLOCK_LIST;
import static io.legaldocml.akn.AknElements.BOOK;
import static io.legaldocml.akn.AknElements.CHANGE;
import static io.legaldocml.akn.AknElements.CHAPTER;
import static io.legaldocml.akn.AknElements.CITATIONS;
import static io.legaldocml.akn.AknElements.CLAUSE;
import static io.legaldocml.akn.AknElements.COMMUNICATION;
import static io.legaldocml.akn.AknElements.CONCEPT;
import static io.legaldocml.akn.AknElements.CONTAINER;
import static io.legaldocml.akn.AknElements.COURT_TYPE;
import static io.legaldocml.akn.AknElements.DATE;
import static io.legaldocml.akn.AknElements.DEBATE;
import static io.legaldocml.akn.AknElements.DEBATE_REPORT;
import static io.legaldocml.akn.AknElements.DEBATE_SECTION;
import static io.legaldocml.akn.AknElements.DECLARATION_OF_VOTE;
import static io.legaldocml.akn.AknElements.DECORATION;
import static io.legaldocml.akn.AknElements.DEF;
import static io.legaldocml.akn.AknElements.DEL;
import static io.legaldocml.akn.AknElements.DIV;
import static io.legaldocml.akn.AknElements.DIVISION;
import static io.legaldocml.akn.AknElements.DOC;
import static io.legaldocml.akn.AknElements.DOCKET_NUMBER;
import static io.legaldocml.akn.AknElements.DOCUMENT_COLLECTION;
import static io.legaldocml.akn.AknElements.DOC_AUTHORITY;
import static io.legaldocml.akn.AknElements.DOC_COMMITTEE;
import static io.legaldocml.akn.AknElements.DOC_DATE;
import static io.legaldocml.akn.AknElements.DOC_INTRODUCER;
import static io.legaldocml.akn.AknElements.DOC_JURISDICTION;
import static io.legaldocml.akn.AknElements.DOC_NUMBER;
import static io.legaldocml.akn.AknElements.DOC_PROPONENT;
import static io.legaldocml.akn.AknElements.DOC_PURPOSE;
import static io.legaldocml.akn.AknElements.DOC_STAGE;
import static io.legaldocml.akn.AknElements.DOC_STATUS;
import static io.legaldocml.akn.AknElements.DOC_TITLE;
import static io.legaldocml.akn.AknElements.DOC_TYPE;
import static io.legaldocml.akn.AknElements.EMBEDDED_STRUCTURE;
import static io.legaldocml.akn.AknElements.EMBEDDED_TEXT;
import static io.legaldocml.akn.AknElements.ENTITY;
import static io.legaldocml.akn.AknElements.EOL;
import static io.legaldocml.akn.AknElements.EOP;
import static io.legaldocml.akn.AknElements.EVENT;
import static io.legaldocml.akn.AknElements.FILL_IN;
import static io.legaldocml.akn.AknElements.FOREIGN;
import static io.legaldocml.akn.AknElements.FORMULA;
import static io.legaldocml.akn.AknElements.HAS_ATTACHMENT;
import static io.legaldocml.akn.AknElements.H_CONTAINER;
import static io.legaldocml.akn.AknElements.INDENT;

/**
 * @author Jacques Militello
 */
public final class Groups {

    static final ImmutableMap> DOCUMENT_TYPE_V2;

    static final ImmutableMap> DOCUMENT_TYPE;

    static {
        DOCUMENT_TYPE_V2 = ImmutableMap.>builder()
                .put(ACT, Act::new)
                .put(AMENDMENT, Amendment::new)
                .put(AMENDMENT_LIST, AmendmentList::new)
                .put(BILL, Bill::new)
                .put(JUDGMENT, Judgment::new)
                .put(DEBATE_REPORT, DebateReport::new)
                .put(DOC, Doc::new)
                .put(DEBATE, Debate::new)
                .put(DOCUMENT_COLLECTION, DocumentCollection::new)
                .put(OFFICIAL_GAZETTE, OfficialGazette::new)
                .build();

        DOCUMENT_TYPE = ImmutableMap.>builder()
                .put(ACT, Act::new)
                .put(AMENDMENT, Amendment::new)
                .put(AMENDMENT_LIST, AmendmentList::new)
                .put(BILL, Bill::new)
                .put(JUDGMENT, Judgment::new)
                .put(DEBATE_REPORT, DebateReport::new)
                .put(DOC, Doc::new)
                .put(DEBATE, Debate::new)
                .put(DOCUMENT_COLLECTION, DocumentCollection::new)
                .put(OFFICIAL_GAZETTE, OfficialGazette::new)
                .put(PORTION, Portion::new)
                .put(STATEMENT, Statement::new)
                .build();
    }

    /**
     * Hide Constructor.
     */
    private Groups() {
    }


    public static  Map> convert(Map> toConvert) {
        ImmutableMap.Builder> builder = ImmutableMap.builder();
        for (Map.Entry> entry : toConvert.entrySet()) {
            builder.put(entry.getKey(), (Supplier) entry.getValue());
        }
        return builder.build();
    }

    public static  Map> convertSuper(Map> toConvert) {
        ImmutableMap.Builder> builder = ImmutableMap.builder();
        for (Map.Entry> entry : toConvert.entrySet()) {
            builder.put(entry.getKey(), (Supplier) entry.getValue());
        }
        return builder.build();
    }


    public static Map> blockElements() {
        ImmutableMap.Builder> builder = ImmutableMap.builder();
        // 
        builder.putAll(convertSuper(ANblock()));
        // 
        builder.putAll(convertSuper(HTMLblock()));
        // 
        builder.put(FOREIGN, Foreign::new);
        // 
        builder.put(BLOCK, Block::new);
        return builder.build();
    }

    public static Map> ANblock() {
        ImmutableMap.Builder> builder = ImmutableMap.builder();
        //
        builder.put(BLOCK_LIST, BlockList::new);
        // 
        builder.put(BLOCK_CONTAINER, BlockContainer::new);
        // 
        builder.put(TOC, Toc::new);
        // 
        builder.put(TBLOCK, Tblock::new);
        return builder.build();
    }


    public static Map> basicContainers() {
        ImmutableMap.Builder> builder = ImmutableMap.builder();
        // 
        builder.put(LONG_TITLE, LongTitle::new);
        // 
        builder.put(FORMULA, Formula::new);
        // 
        builder.put(CONTAINER, Container::new);
        return builder.build();
    }

    public static Map> prefaceContainers() {
        ImmutableMap.Builder> builder = ImmutableMap.builder();
        // 
        builder.put(LONG_TITLE, LongTitle::new);
        // 
        builder.put(FORMULA, Formula::new);
        // 
        builder.put(CONTAINER, Container::new);
        return builder.build();
    }


    public static Map> inlineCM() {

        ImmutableMap.Builder> builder = ImmutableMap.builder();
        //
        builder.putAll(convertSuper(inlineElements()));
        //
        builder.putAll(convertSuper(markerElements()));
        //
        builder.putAll(convertSuper(popupElements()));
        return builder.build();
    }

    public static Map> HTMLblock() {

        ImmutableMap.Builder> builder = ImmutableMap.builder();
        // 
        builder.put(UL, Ul::new);
        // 
        builder.put(OL, Ol::new);
        // 
        builder.put(TABLE, Table::new);
        // 
        builder.put(AknElements.P, P::new);
        return builder.build();
    }


    public static Map> popupElements() {
        ImmutableMap.Builder> builder = ImmutableMap.builder();
        // 
        builder.putAll(convertSuper(ANsubFlow()));
        // 
        //builder.put(Popup.ELEMENT, Popup::new);
         //
        builder.put(SUB_FLOW, SubFlow::new);
        return builder.build();
    }


    public static Map> inlineElements() {

        ImmutableMap.Builder> builder = ImmutableMap.builder();
        //
        builder.putAll(convertSuper(ANinline()));
        //
        builder.putAll(convertSuper(HTMLinline()));
        //
        builder.putAll(convertSuper(ANtitleInline()));
        //
        builder.putAll(convertSuper(ANsemanticInline()));
        //
        builder.putAll(convertSuper(ANheaderInline()));
        //
        builder.putAll(convertSuper(amendmentInline()));
        //
        builder.put(INLINE, Inline::new);

        return builder.build();
    }

    private static Map> HTMLinline() {

        ImmutableMap.Builder> builder = ImmutableMap.builder();
        // 
        builder.put(B, B::new);
        // 
        builder.put(AknElements.I, I::new);
        // 
        builder.put(A, A::new);
        // 
        builder.put(AknElements.U, U::new);
        // 
        builder.put(SUB, Sub::new);
        // 
        builder.put(SUP, Sup::new);
        // 
        builder.put(ABBR, Abbr::new);
        // 
        builder.put(SPAN, Span::new);

        return builder.build();
    }

    private static Map> ANinline() {

        ImmutableMap.Builder> builder = ImmutableMap.builder();
        // 
        builder.put(REF, Ref::new);
        // 
        builder.put(MREF, Mref::new);
        // 
        builder.put(RREF, Rref::new);
        // 
        builder.put(MOD, Mod::new);
        // 
        builder.put(MMOD, Mmod::new);
        // 
        builder.put(RMOD, Rmod::new);
        // 
        builder.put(REMARK, Remark::new);
        // 
        builder.put(RECORDED_TIME, RecordedTime::new);
        // 
        builder.put(VOTE, Vote::new);
        // 
        builder.put(OUTCOME, Outcome::new);
        // 
        builder.put(INS, Ins::new);
        // 
        builder.put(DEL, Del::new);
        // 
        builder.put(OMISSIS, Omissis::new);
        // 
        builder.put(EMBEDDED_TEXT, EmbeddedText::new);
        // 
        builder.put(EMBEDDED_STRUCTURE, EmbeddedStructure::new);
        // 
        builder.put(OPINION, Opinion::new);
        // 
        builder.put(PLACE_HOLDER, Placeholder::new);
        // 
        builder.put(FILL_IN, FillIn::new);
        // 
        builder.put(DECORATION, Decoration::new);

        // V2
        builder.put(ExtractText.ELEMENT, ExtractText::new);
        builder.put(ExtractStructure.ELEMENT, ExtractStructure::new);
        return builder.build();
    }

    private static Map> amendmentInline() {
        ImmutableMap.Builder> builder = ImmutableMap.builder();
        // 
        builder.put(AFFECTED_DOCUMENT, AffectedDocument::new);
        // 
        builder.put(RELATED_DOCUMENT, RelatedDocument::new);
        // 
        builder.put(CHANGE, Change::new);
        return builder.build();
    }

    private static Map> HTMLMarker() {
        ImmutableMap.Builder> builder = ImmutableMap.builder();
        // 
        builder.put(IMG, Img::new);
        // 
        builder.put(BR, Br::new);
        return builder.build();
    }

    public static Map> markerElements() {
        ImmutableMap.Builder> builder = ImmutableMap.builder();
        // 
        builder.putAll(convertSuper(ANmarker()));
        // 
        builder.putAll(convertSuper(HTMLMarker()));
        // 
        builder.put(MARKER, Marker::new);
        return builder.build();
    }

    public static Map> ANmarker() {
        ImmutableMap.Builder> builder = ImmutableMap.builder();
        // 
        builder.put(NOTE_REF, NoteRef::new);
        // 
        builder.put(EOL, Eol::new);
        // 
        builder.put(EOP, Eop::new);
        return builder.build();
    }

    public static Map> ANsemanticInline() {
        ImmutableMap.Builder> builder = ImmutableMap.builder();
        // 
        builder.put(DATE, Date::new);
        // 
        builder.put(TIME, Time::new);
        // 
        builder.put(PERSON, Person::new);
        // 
        builder.put(ORGANIZATION, Organization::new);
        // 
        builder.put(CONCEPT, Concept::new);
        // 
        builder.put(OBJECT, Object::new);
        // 
        builder.put(EVENT, Event::new);
        // 
        builder.put(LOCATION, Location::new);
        // 
        builder.put(PROCESS, Process::new);
        // 
        builder.put(ROLE, Role::new);
        // 
        builder.put(TERM, Term::new);
        // 
        builder.put(QUANTITY, Quantity::new);
        // 
        builder.put(DEF, Def::new);
        // 
        builder.put(ENTITY, Entity::new);
        return builder.build();
    }

    public static Map> ANheaderInline() {
        ImmutableMap.Builder> builder = ImmutableMap.builder();
        // 
        builder.put(COURT_TYPE, CourtType::new);
        // 
        builder.put(NEUTRAL_CITATION, NeutralCitation::new);
        // 
        builder.put(PARTY, Party::new);
        // 
        builder.put(JUDGE, Judge::new);
        // 
        builder.put(LAWYER, Lawyer::new);
        // 
        builder.put(SIGNATURE, Signature::new);
        // 
        builder.put(ARGUMENT, Argument::new);
        return builder.build();
    }

    public static Map> ANtitleInline() {
        ImmutableMap.Builder> builder = ImmutableMap.builder();
        // 
        builder.put(DOC_TYPE, DocType::new);
        //
        builder.put(DOC_TITLE, DocTitle::new);
        // 
        builder.put(DOC_NUMBER, DocNumber::new);
        // 
        builder.put(DOC_PROPONENT, DocProponent::new);
        // 
        builder.put(DOC_DATE, DocDate::new);
        // 
        builder.put(LEGISLATURE, Legislature::new);
        // 
        builder.put(SESSION, Session::new);
        // 
        builder.put(SHORT_TITLE, ShortTitle::new);
        // 
        builder.put(DOC_AUTHORITY, DocAuthority::new);
        // 
        builder.put(DOC_PURPOSE, DocPurpose::new);
        // 
        builder.put(DOC_COMMITTEE, DocCommittee::new);
        // 
        builder.put(DOC_INTRODUCER, DocIntroducer::new);
        // 
        builder.put(DOC_STAGE, DocStage::new);
        // 
        builder.put(DOC_STATUS, DocStatus::new);
        // 
        builder.put(DOC_JURISDICTION, DocJurisdiction::new);
        // 
        builder.put(DOCKET_NUMBER, DocketNumber::new);
        return builder.build();
    }

    private static Map> ANsubFlow() {
        ImmutableMap.Builder> builder = ImmutableMap.builder();
        // 
        builder.put(AUTHORIAL_NOTE, AuthorialNote::new);
        return builder.build();
    }

    static Map> docRefs() {
        ImmutableMap.Builder> builder = ImmutableMap.builder();
        // 
        builder.put(ORIGINAL, Original::new);
        // 
        builder.put(PASSIVE_REF, PassiveRef::new);
        // 
        builder.put(ACTIVE_REF, ActiveRef::new);
        // 
        builder.put(JURISPRUDENCE, Jurisprudence::new);
        // 
        builder.put(HAS_ATTACHMENT, HasAttachment::new);
        // 
        builder.put(ATTACHMENT_OF, AttachmentOf::new);
        return builder.build();
    }

    static Map> TLCs() {
        ImmutableMap.Builder> builder = ImmutableMap.builder();
        // 
        builder.put(TLC_PERSON, TLCPerson::new);
        // 
        builder.put(TLC_ORGANIZATION, TLCOrganization::new);
        // 
        builder.put(TLC_CONCEPT, TLCConcept::new);
        // 
        builder.put(TLC_OBJECT, TLCObject::new);
        // 
        builder.put(TLC_EVENT, TLCEvent::new);
        // 
        builder.put(TLC_LOCATION, TLCLocation::new);
        // 
        builder.put(TLC_PROCESS, TLCProcess::new);
        // 
        builder.put(TLC_ROLE, TLCRole::new);
        // 
        builder.put(TLC_TERM, TLCTerm::new);
        // 
        builder.put(TLC_REFERENCE, TLCReference::new);
        return builder.build();
    }

    public static Map> preambleContainers() {
        ImmutableMap.Builder> builder = ImmutableMap.builder();
        // 
        builder.put(RECITALS, Recitals::new);
        // 
        builder.put(CITATIONS, Citations::new);
        // 
        builder.put(FORMULA, Formula::new);
        // 
        builder.put(CONTAINER, Container::new);
        return builder.build();
    }

    public static Map> hierElements() {
        ImmutableMap.Builder> builder = ImmutableMap.builder();
        // 
        builder.putAll(convertSuper(ANhier()));
        // 
        builder.put(H_CONTAINER, Hcontainer::new);
        return builder.build();
    }

    public static Map> ANhier() {
        ImmutableMap.Builder> builder = ImmutableMap.builder();
        // 
        builder.put(CLAUSE, Clause::new);
        // 
        builder.put(SECTION, Section::new);
        // 
        builder.put(PART, Part::new);
        // 
        builder.put(PARAGRAPH, Paragraph::new);
        // 
        builder.put(CHAPTER, Chapter::new);
        // 
        builder.put(TITLE, Title::new);
        // 
        builder.put(ARTICLE, Article::new);
        // 
        builder.put(BOOK, Book::new);
        // 
        builder.put(TOME, Tome::new);
        // 
        builder.put(DIVISION, Division::new);
        // 
        builder.put(LIST, List::new);
        // 
        builder.put(POINT, Point::new);
        // 
        builder.put(INDENT, Indent::new);
        // 
        builder.put(ALINEA, Alinea::new);
        // 
        builder.put(RULE, Rule::new);
        // 
        builder.put(SUB_RULE, Subrule::new);
        // 
        builder.put(PROVISO, Proviso::new);
        // 
        builder.put(SUB_SECTION, Subsection::new);
        // 
        builder.put(SUB_PART, Subpart::new);
        // 
        builder.put(SUB_PARAGRAPH, Subparagraph::new);
        // 
        builder.put(SUB_CHAPTER, Subchapter::new);
        // 
        builder.put(SUB_TITLE, Subtitle::new);
        // 
        builder.put(SUB_DIVISION, Subdivision::new);
        // 
        builder.put(SUB_CLAUSE, Subclause::new);
        // 
        builder.put(SUB_LIST, Sublist::new);
        // 
        builder.put(LEVEL, Level::new);
        // 
        builder.put(TRANSITIONAL, Transitional::new);
        return builder.build();
    }

    public static Map> containerElements() {
        ImmutableMap.Builder> builder = ImmutableMap.builder();
        // 
        builder.putAll(convertSuper(speechSection()));
        // 
        builder.putAll(convertSuper(HTMLcontainers()));
        // 
        builder.put(CONTAINER, Container::new);
        return builder.build();
    }

    public static Map> HTMLcontainers() {
        ImmutableMap.Builder> builder = ImmutableMap.builder();
        // 
        builder.put(DIV, Div::new);
        return builder.build();
    }

    public static Map> ANcontainers() {
        ImmutableMap.Builder> builder = ImmutableMap.builder();
        //
        builder.put(SPEECH, Speech::new);
        // 
        builder.put(QUESTION, Question::new);
        // 
        builder.put(ANSWER, Answer::new);
        // 
        builder.put(OTHER, Other::new);
        // 
        builder.put(SCENE, Scene::new);
        // 
        builder.put(NARRATIVE, Narrative::new);
        // 
        builder.put(SUMMARY, Summary::new);
        return builder.build();
    }

    public static Map> speechSection() {
        ImmutableMap.Builder> builder = ImmutableMap.builder();
        // 
        builder.put(ADMINISTATION_OF_OATH, AdministrationOfOath::new);
        // 
        builder.put(ROLL_CALL, RollCall::new);
        // 
        builder.put(PRAYERS, Prayers::new);
        // 
        builder.put(ORAL_STATEMENTS, OralStatements::new);
        // 
        builder.put(WRITTEN_STATEMENTS, WrittenStatements::new);
        // 
        builder.put(PERSONAL_STATEMENTS, PersonalStatements::new);
        // 
        builder.put(MINISTERIAL_STATEMENTS, MinisterialStatements::new);
        // 
        builder.put(RESOLUTIONS, Resolutions::new);
        // 
        builder.put(NATIONAL_INTEREST, NationalInterest::new);
        // 
        builder.put(DECLARATION_OF_VOTE, DeclarationOfVote::new);
        // 
        builder.put(COMMUNICATION, Communication::new);
        // 
        builder.put(PETITIONS, Petitions::new);
        // 
        builder.put(PAPERS, Papers::new);
        // 
        builder.put(NOTICES_OF_MOTION, NoticesOfMotion::new);
        // 
        builder.put(QUESTIONS, Questions::new);
        // 
        builder.put(ADDRESS, Address::new);
        // 
        builder.put(PROCEDURAL_MOTIONS, ProceduralMotions::new);
        // 
        builder.put(POINT_OF_ORDER, PointOfOrder::new);
        // 
        builder.put(ADJOURNMENT, Adjournment::new);
        // 
        builder.put(DEBATE_SECTION, DebateSection::new);
        return builder.build();
    }


    public static ImmutableMap> getDocumentTypes(XmlReader reader) {
        if (reader.getContext().getAkoXmlModule().getVersion() == 2) {
            return DOCUMENT_TYPE_V2;
        }
        return DOCUMENT_TYPE;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy