Appium+selenium代码阅读笔记-判空写法-Optional

1. debug appium的代码,看到了判空写法,比较有趣,记录一下。

2.妈个鸡我真是源码黑洞。

在看appium的源码,打断点追踪,想看看appium的元素定位到底怎么写的。画调用图的时候头炸开。

里面把java操作输出成js的命令是这样的,这个类是selenium的JsonOutput类,本来以为stream我已经用的很熟了,直到我看到了.map(Map.Entry::getValue),我裂开。

  public JsonOutput write(Object input, int depthRemaining) {
    converters.entrySet().stream()
        .filter(entry -> entry.getKey().test(input == null ? null : input.getClass()))
        .findFirst()
        .map(Map.Entry::getValue)
        .orElseThrow(() -> new JsonException("Unable to write " + input))
        .consume(input, depthRemaining);

    return this;
  }

 

开始补课Optional部分。

补课中... 

3.用了很多guava包的方法,没接触过,mark下,待补课。

https://guava.dev/releases/18.0/api/docs/com/google/common/reflect/package-summary.html

 4.ServiceLoader.load();

5.ImmutableSet的static add()和static build()是做什么的?

 6.HashMap.getOrDefault()

原文地址:https://www.cnblogs.com/zhizhiyin/p/14060076.html