0

How can I map the data to four values for the BalanceDTO instead of two like in the example I made for the NetDTO. Any help will be appreciated, I want to find the 4 values to map them. I just need help in the loop to find the values. Thanks in Advance.

/// 2 values CSV File
public void toCSVFile(List<ReceivedData> receivedDataList) {

        logger.info("Executing net value strategy...");

        List<ReceivedData> secondaryList = receivedDataList;

        List<NetDTO> netDTOList = new ArrayList<>();

        //maps data to netDTO, finds minuend and subtrahend
        for (ReceivedData y : receivedDataList) {

            for (ReceivedData x : secondaryList) {
                if (y.getLotid().equals(x.getLotid()) && y.getMaterialNumber().equals(x.getMaterialNumber()) && y.getOperKey().equals(x.getOperKey()) && y.getOrderID().equals(x.getOrderID()) &&
                        y.getSerialID().equals(x.getSerialID()) && y.getStepKey().equals(x.getStepKey()) &&
                        !y.getDataCollectionID().equals(x.getDataCollectionID()) && y.getType().equals("MINUEND") && x.getType().equals("SUBTRAHEND")) {

                    NetDTO netDTO = new NetDTO(y, x);

                    netDTOList.add(netDTO);
                }
            }
        }
        writer(receivedDataList.get(0).getProcess().getProcessName() + ".csv", netDTOList);
    }

///// Net DTO
public NetDTO(ReceivedData minuend, ReceivedData subtrahend) {
        this.ordNumber = minuend.getOrdNumber();
        this.matNumber = minuend.getMaterialNumber();
        this.operator = minuend.getOperator();
        this.serialNumber = minuend.getSerialNumber();
        this.toolNo = minuend.getToolNo();
        this.timeStamp = minuend.getTimeStamp();

        this.dcTitleMinuend = minuend.getDcTitle();
        this.dcValueMinuend = minuend.getDcValue();

        this.dcTitleSubtrahend = subtrahend.getDcTitle();
        this.dcValueSubtrahend = subtrahend.getDcValue();

    }

//// Balance DTO (I want to map the data like I did in the netDTO to this dto. But with 4 values)

 public BalanceDTO(ReceivedData value1, ReceivedData value2, ReceivedData value3, ReceivedData value4) {
        this.ordNumber = value1.getOrdNumber();
        this.matNumber = value1.getMaterialNumber();
        this.operator = value1.getOperator();
        this.serialNumber = value1.getSerialNumber();
        this.toolNo = value1.getToolNo();
        this.timeStamp = value1.getTimeStamp();

        this.dcTitleValue1 = value1.getDcTitle();
        this.dcValueValue1 = value1.getDcValue();

        this.dcTitleValue2 = value2.getDcTitle();
        this.dcValueValue2 = value2.getDcValue();

        this.dcTitleValue3 = value3.getDcTitle();
        this.dcValueValue3 = value3.getDcValue();

        this.dcTitleValue4 = value4.getDcTitle();
        this.dcValueValue4 = value4.getDcValue();

    }

I wan to know how can I approach the looping when it comes 3 or more values. In this case, 4 values.

0 Answers0