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

pro.verron.officestamper.preset.StampTable Maven / Gradle / Ivy

Go to download

Office-stamper is a Java template engine for docx documents, forked from org.wickedsource.docx-stamper

The newest version!
package pro.verron.officestamper.preset;

import org.springframework.lang.NonNull;

import java.util.*;

import static java.util.Collections.singletonList;

/**
 * Represents a table with several columns, a header line, and several lines of content
 *
 * @author Joseph Verron
 * @version ${version}
 * @since 1.6.2
 */
public class StampTable
        extends AbstractSequentialList> {
    private final List headers;
    private final List> records;

    @Override public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        if (!super.equals(o)) return false;
        StampTable lists = (StampTable) o;
        return Objects.equals(headers, lists.headers) && Objects.equals(records, lists.records);
    }

    @Override public int hashCode() {
        return Objects.hash(super.hashCode(), headers, records);
    }

    /**
     * Instantiate an empty table
     */
    public StampTable() {
        this.headers = new ArrayList<>();
        this.records = new ArrayList<>();
    }

    /**
     * Instantiate a table with headers and several lines
     *
     * @param headers the header lines
     * @param records the lines that the table should contain
     */
    public StampTable(
            @NonNull List headers,
            @NonNull List> records
    ) {
        this.headers = headers;
        this.records = records;
    }

    @Override
    public int size() {
        return records.size();
    }

    @Override
    @NonNull
    public ListIterator> listIterator(int index) {
        return records.listIterator(index);
    }

    /**
     * 

empty.

* * @return a {@link StampTable} object */ public static StampTable empty() { return new StampTable( singletonList("placeholder"), singletonList(singletonList("placeholder")) ); } /** *

headers.

* * @return a {@link List} object */ public List headers() { return headers; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy