package com.knecon.fforesight.service.layoutparser.processor.model.graph.nodes;

import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.NodeType;

import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.FieldDefaults;
import lombok.experimental.SuperBuilder;

@Data
@SuperBuilder
@AllArgsConstructor
@FieldDefaults(level = AccessLevel.PRIVATE)
@EqualsAndHashCode(callSuper = true)
public class SuperSection extends AbstractSemanticNode {

    @Override
    public NodeType getType() {

        return NodeType.SUPER_SECTION;
    }


    public Headline getHeadline() {

        return streamChildrenOfType(NodeType.HEADLINE).map(node -> (Headline) node)
                .findFirst()
                .orElseGet(() -> getParent().getHeadline());
    }


    @Override
    public String toString() {

        return getTreeId() + ": " + NodeType.SUPER_SECTION + ": " + this.getTextBlock().buildSummary();
    }

}
