一、代码实现
1.数组转换成List
String[] deviceIdAy = buildingDto.getChannelId().split(Symbol.COMMA);
//设备id
List<String> deviceIdList = Arrays.asList(deviceIdAy);
2.List转换成数组
List<String> gatemateIdList = buildingDao.listBuildingDeviceId(buildingDeviceCond);
String[] deviceIdAy = gatemateIdList.toArray(new String[gatemateIdList.size()]);
3.List数组拼接到另外一个List后面(channelDtoListTo放到channelDtoList后面)
List<ChannelDTO> channelDtoListTo = buildingDao.listChannel(channelCondTo);
channelDtoListTo.stream().sequential().collect(Collectors.toCollection(() -> channelDtoList));
3.List的stream的用法
1.map 用来对list中的单独对象进行全体修改然后返回一个list回来
Set<String> roleList = roles.stream().map(role -> "ROLE_" + role.toUpperCase()).collect(Collectors.toSet());
1.filter 用来过滤符合条件的数据,然后返回一个list
selfStudyClassroomDtoList = selfStudyClassroomDtoList.stream().filter(s -> s.getWeekDay().equals(w)).collect(Collectors.toList());