类 StreamUtil

java.lang.Object
org.dromara.dynamictp.common.util.StreamUtil

public final class StreamUtil extends Object
StreamUtil related
从以下版本开始:
1.0.0
作者:
yanhom
  • 方法详细资料

    • fetchProperty

      public static <I, T> List<I> fetchProperty(Collection<T> data, Function<T,I> mapping)
      Fetches id to list.
      类型参数:
      I - id type
      T - data type
      参数:
      data - data collection
      mapping - calculate the id in data list
      返回:
      a list of id
    • toMap

      public static <P, O> Map<O,P> toMap(Collection<P> coll, Function<P,O> key)
      Converts to map (key from the list data)
      类型参数:
      O - id type
      P - data type
      参数:
      coll - data list
      key - key mapping function
      返回:
      a map which key from list data and value is data
    • toMap

      public static <O, D, P> Map<O,P> toMap(Collection<D> list, Function<D,O> key, Function<D,P> value)
      Converts to map (key from the list data)
      类型参数:
      O - id type
      D - data type
      P - value type
      参数:
      list - data list
      key - key mapping function
      value - value mapping function
      返回:
      a map which key from list data and value is data
    • toListMap

      public static <I, D> Map<I,List<D>> toListMap(Collection<I> ids, Collection<D> list, Function<D,I> key)
      Converts a list to a list map where list contains id in ids.
      类型参数:
      I - id type
      D - data type
      参数:
      ids - id collection
      list - data list
      key - calculate the id in data list
      返回:
      a map which key is in ids and value containing in list