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.GruppoArticoloDTO;

public class DialogSelectDocInfo_GroupArtAdapter extends ArrayAdapter<DialogSelectDocInfo_GroupArtAdapter.ListModel> {

    public DialogSelectDocInfo_GroupArtAdapter(@NonNull Context context, int resource, List<GruppoArticoloDTO> 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 GruppoArticoloDTO originalModel;

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

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

}
