Class CollectionUtil

java.lang.Object
cn.net.pap.common.datastructure.collection.CollectionUtil

public class CollectionUtil extends Object
集合工具类
  • Constructor Details

    • CollectionUtil

      public CollectionUtil()
  • Method Details

    • groupList

      public static List<List<String>> groupList(List<String> largeList, int groupSize)
      将列表按照指定大小分组
      Parameters:
      largeList - 要分组的大列表
      groupSize - 每个分组的大小
      Returns:
      包含分组后子列表的列表
    • getNextChild

      public static String getNextChild(String currentLevel)
      获取下一个子节点
      Parameters:
      currentLevel -
      Returns:
    • getNextSibling

      public static String getNextSibling(String currentLevel)
      获取下一个兄弟节点
      Parameters:
      currentLevel -
      Returns:
    • exitThenGetNextSibling

      public static String exitThenGetNextSibling(String currentLevel)
      跳出当前层级并在上一个层级中+1
      Parameters:
      currentLevel -
      Returns:
    • batchByProperty

      public static <T, R> List<List<R>> batchByProperty(List<T> list, int batchSize, Function<T,R> propertyExtractor)
      安全分批处理方法
      Type Parameters:
      T - 原始元素类型
      R - 结果元素类型
      Parameters:
      list - 原始集合(可为空)
      batchSize - 每批大小(必须大于0)
      propertyExtractor - 属性提取函数(不可为null)
      Returns:
      分批后的结果列表(永远不会返回null)
      Throws:
      IllegalArgumentException - 如果参数不合法