package it.integry.integrywmsnative.gest.contab_doc_interni.dialog.adapter;

import android.content.Context;
import android.widget.ArrayAdapter;

import androidx.annotation.NonNull;

import com.annimon.stream.Stream;

import java.util.List;

import it.integry.integrywmsnative.gest.contab_doc_interni.dto.TipoDocDTO;

public class DialogSelectDocInfo_TipoDocAdapter extends ArrayAdapter<DialogSelectDocInfo_TipoDocAdapter.ListModel> {

    public DialogSelectDocInfo_TipoDocAdapter(@NonNull Context context, int resource, List<TipoDocDTO> inputData) {
        super(context, resource);

        if(inputData == null) return;

        List<ListModel> mDataset = Stream.of(inputData)
                .map(x -> new ListModel()
                        .setOriginalModel(x))
                .toList();

        addAll(mDataset);
    }

    public static class ListModel {

        private TipoDocDTO originalModel;

        public TipoDocDTO getOriginalModel() {
            return originalModel;
        }
        public ListModel setOriginalModel(TipoDocDTO originalModel) {
            this.originalModel = originalModel;
            return this;
        }

        @Override
        public String toString() {
            return this.getOriginalModel().getCodDtip() + " - " + this.getOriginalModel().getDescrizione();
        }
    }

}
