KeyPath.java 文件源码

java
阅读 36 收藏 0 点赞 0 评论 0

项目:lottie-android 作者:
/**
 * For a given key and depth, returns how much the depth should be incremented by when
 * resolving a keypath to children.
 *
 * This can be 0 or 2 when there is a globstar and the next key either matches or doesn't match
 * the current key.
 */
@RestrictTo(RestrictTo.Scope.LIBRARY)
public int incrementDepthBy(String key, int depth) {
  if (isContainer(key)) {
    // If it's a container then we added programatically and it isn't a part of the keypath.
    return 0;
  }
  if (!keys.get(depth).equals("**")) {
    // If it's not a globstar then it is part of the keypath.
    return 1;
  }
  if (depth == keys.size() - 1) {
    // The last key is a globstar.
    return 0;
  }
  if (keys.get(depth + 1).equals(key)) {
    // We are a globstar and the next key is our current key so consume both.
    return 2;
  }
  return 0;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号