Blame view

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