Blame view

src/main/java/cn/iocoder/dashboard/util/collection/ArrayUtils.java 803 Bytes
4120084c   YunaiV   完成 dict type 的单元测试
1
2
3
4
  package cn.iocoder.dashboard.util.collection;
  
  import cn.hutool.core.util.ArrayUtil;
  
113e34b2   YunaiV   完善 dict data 的单元测试
5
6
  import java.util.function.Consumer;
  
4120084c   YunaiV   完成 dict type 的单元测试
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
  /**
   * Array 工具类
   *
   * @author 芋道源码
   */
  public class ArrayUtils {
  
      /**
       * 将 object 和 newElements 合并成一个数组
       *
       * @param object 对象
       * @param newElements 数组
       * @param <T> 泛型
       * @return 结果数组
       */
      @SafeVarargs
113e34b2   YunaiV   完善 dict data 的单元测试
23
      public static <T> Consumer<T>[] append(Consumer<T> object, Consumer<T>... newElements) {
4120084c   YunaiV   完成 dict type 的单元测试
24
25
26
          if (object == null) {
              return newElements;
          }
113e34b2   YunaiV   完善 dict data 的单元测试
27
          Consumer<T>[] result = ArrayUtil.newArray(Consumer.class, 1 + newElements.length);
4120084c   YunaiV   完成 dict type 的单元测试
28
29
30
31
32
33
          result[0] = object;
          System.arraycopy(newElements, 0, result, 1, newElements.length);
          return result;
      }
  
  }