企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
## 3.2 流操作 流的使用包含三件事: - 从数据源获取流 - 多个中间操作,组成流水线 - 一个终端操作,生成结果 本节的内容将会用到以下的`Model`类以及`DATA`: ```java import java.util.Arrays; import java.util.List; public class StreamDemo { public static void main(String[] args) { } static final List<Model> DATA = Arrays.asList( new Model(1, "A", 121.43, true), new Model(1, "B", 14.5, false), new Model(2, "C", 22.4, true), new Model(2, "D", 11.22, false), new Model(3, "E", 0.32, true), new Model(3, "F", 11.3, false), new Model(3, "G", 93.23, true) ); static class Model { String name; int type; double value; boolean success; public Model(int type, String name, double value, boolean success) { this.name = name; this.type = type; this.value = value; this.success = success; } public String getName() { return name; } public void setName(String name) { this.name = name; } public int getType() { return type; } public void setType(int type) { this.type = type; } public double getValue() { return value; } public void setValue(double value) { this.value = value; } public boolean getSuccess() { return success; } public void setSuccess(boolean success) { this.success = success; } } } ```