lambda表达式

filter

# 过滤出名称空间不属于kube-system的pod

  List pods = KubernetesClientUtil.getKubernetesClient().pods().inAnyNamespace().list().getItems();
  pods = pods.stream().filter(
          pod -> !"kube-system".equals(pod.getMetadata().getNamespace())
  ).collect(Collectors.toList());

forEach

public static Lifecycle getLifecycle(List commands){
        List commandList=new ArrayList<>();
        commandList.add("/bin/bash");
        commandList.add("-c");
        commands.stream().forEach(command->{
            commandList.add(command);
        });
        
        ExecAction execAction = new ExecAction();
        execAction.setCommand(commandList);
        Handler handler = new Handler();
        handler.setExec(execAction);
        Lifecycle lifecycle = new Lifecycle();
        lifecycle.setPostStart(handler);
        return lifecycle;
    }

你可能感兴趣的:(jdk)