#
luxiaotao1123
2024-11-05 fe4c6c0439e0dc00f0b09d1818735065d38d3078
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package com.zy.acs.manager.core.domain;
 
import com.zy.acs.common.utils.GsonUtils;
import lombok.Data;
 
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
 
/**
 * Created by vincent on 11/5/2024
 */
@Data
public class BlockVehicleDto {
 
    private String vehicle;
 
    private boolean avoidable;
 
    public BlockVehicleDto() {
    }
 
    public BlockVehicleDto(String vehicle, boolean avoidable) {
        this.vehicle = vehicle;
        this.avoidable = avoidable;
    }
 
    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        BlockVehicleDto that = (BlockVehicleDto) o;
        return Objects.equals(vehicle, that.vehicle);
    }
 
    @Override
    public int hashCode() {
        return Objects.hash(vehicle);
    }
 
    public static void main(String[] args) {
        List<BlockVehicleDto> blockVehicleList = new ArrayList<>();
        blockVehicleList.add(new BlockVehicleDto("1", true));
        blockVehicleList.add(new BlockVehicleDto("2", true));
//        blockVehicleList.add(new BlockVehicleDto("3", false));
//        blockVehicleList.add(new BlockVehicleDto("4", false));
//        blockVehicleList.add(new BlockVehicleDto("5", false));
//        blockVehicleList.add(new BlockVehicleDto("5", true));
//        blockVehicleList.add(new BlockVehicleDto("4", true));
 
        System.out.println(GsonUtils.toJson(blockVehicleList));
        System.out.println(GsonUtils.toJson(blockVehicleList.stream().distinct().collect(Collectors.toList())));
 
        System.out.println(blockVehicleList.stream().anyMatch(blockVehicleDto -> !blockVehicleDto.isAvoidable()));
 
        String blockAgvNo = blockVehicleList.stream()
                .filter(BlockVehicleDto::isAvoidable)
                .map(BlockVehicleDto::getVehicle)
                .findFirst().orElse(null);
        System.out.println(blockAgvNo);
    }
 
}