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

com.alphasystem.docbook.builder.impl.block.ListItemBuilder Maven / Gradle / Ivy

The newest version!
package com.alphasystem.docbook.builder.impl.block;


import com.alphasystem.docbook.builder.Builder;
import com.alphasystem.docbook.builder.impl.AbstractBuilder;
import com.alphasystem.docbook.util.Utils;
import com.alphasystem.xml.UnmarshallerConstants;
import org.docbook.model.ListItem;

import java.util.List;

public class ListItemBuilder extends AbstractBuilder {

    /*
     * In a list if there are multiple paragraphs, then we only need to set "NumPr" on the first para.
     * The id is the id of first such para.
     */
    protected String firstParaId = null;

    public ListItemBuilder(ListItem source, Builder parent) {
        super(source, parent);
    }

    public String getFirstParaId() {
        return firstParaId;
    }

    private void setFirstParaId(Object o) {
        this.firstParaId = Utils.getId(o);
    }

    @Override
    protected List processChildContent(List childContent) {
        childContent.stream().filter(UnmarshallerConstants::isParaTypes).findFirst()
                .ifPresent(this::setFirstParaId);
        return super.processChildContent(childContent);
    }
}