如何将Stream <arrayofobject>转换为List <object>?

时间:2019-03-30 19:05:19

标签: java arrays object java-stream

我是流媒体新手,需要转换流

public PayeeFacilityResponse searchPayeeFacility(String providerTaxID) {
        PayeeFacilityResponse payeeFacilityResponse = new PayeeFacilityResponse();
        if (StringUtils.isNotEmpty(providerTaxID)) {
            Doc doc = null;
            try {
                doc = getPayeeFacilityDoc(providerTaxID);
            } catch (Exception e) {
                e.printStackTrace();
                return null;
            }


            Stream<ArrayOfPayeeFacility> facilityStream = doc.objects("//*[local-name()='PayeeFacilities']", ArrayOfPayeeFacility.class);
            List<PayeeFacility> payeeFacilityList = new ArrayList<>();
            //need to convert facilityStream to ArrayofPayeeFacility
            ArrayOfPayeeFacility arrayOfPayeeFacility = new ArrayOfPayeeFacility();


            payeeFacilityResponse.setPayeeFacilities(arrayOfPayeeFacility);
        }
        return payeeFacilityResponse;
    }

这是ArrayOfPayeeFacility

public class ArrayOfPayeeFacility {

    protected List<PayeeFacility> payeeFacility;

    public ArrayOfPayeeFacility() {
    }

    public List<PayeeFacility> getPayeeFacility() {
        if (this.payeeFacility == null) {
            this.payeeFacility = new ArrayList();
        }

        return this.payeeFacility;
    }
}

如何将工具流转换为列表? ArrayofPayeeFacility包含列表

0 个答案:

没有答案