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

import java.util.Set;
import java.util.function.BiConsumer;
import java.util.function.BinaryOperator;
import java.util.function.Function;
import java.util.function.Supplier;
import java.util.stream.Collector;

import lombok.NoArgsConstructor;

@NoArgsConstructor
public class TextBlockCollector implements Collector<TextBlock, ConcatenatedTextBlock, TextBlock> {

    @Override
    public Supplier<ConcatenatedTextBlock> supplier() {

        return ConcatenatedTextBlock::empty;
    }


    @Override
    public BiConsumer<ConcatenatedTextBlock, TextBlock> accumulator() {

        return ConcatenatedTextBlock::concat;
    }


    @Override
    public BinaryOperator<ConcatenatedTextBlock> combiner() {

        return ConcatenatedTextBlock::concat;
    }


    @Override
    public Function<ConcatenatedTextBlock, TextBlock> finisher() {

        return a -> a;
    }


    @Override
    public Set<Characteristics> characteristics() {

        return Set.of(Characteristics.IDENTITY_FINISH, Characteristics.CONCURRENT);
    }

}
