zoukankan      html  css  js  c++  java
  • Spring core中一些API

    一个好用的api

        /**
         * Convert the given array (which may be a primitive array) to an
         * object array (if necessary of primitive wrapper objects).
         * <p>A {@code null} source value will be converted to an
         * empty Object array.
         * @param source the (potentially primitive) array
         * @return the corresponding object array (never {@code null})
         * @throws IllegalArgumentException if the parameter is not an array
         */
        public static Object[] toObjectArray(@Nullable Object source) {
            if (source instanceof Object[]) {
                return (Object[]) source;
            }
            if (source == null) {
                return new Object[0];
            }
            if (!source.getClass().isArray()) {
                throw new IllegalArgumentException("Source is not an array: " + source);
            }
            int length = Array.getLength(source);
            if (length == 0) {
                return new Object[0];
            }
            Class<?> wrapperType = Array.get(source, 0).getClass();
            Object[] newArray = (Object[]) Array.newInstance(wrapperType, length);
            for (int i = 0; i < length; i++) {
                newArray[i] = Array.get(source, i);
            }
            return newArray;
        }

    org.springframework.util.ObjectUtils#toObjectArray

    Arrays.stream(ObjectUtils.toObjectArray(new byte[]{1,2,3})).map(String::valueOf).collect(Collectors.joining(","))
  • 相关阅读:
    极验验证(滑动验证)的使用
    from close /destory
    tmeminifile and tinifile
    Delphi的OverRide、OverLoad和Virtual方法
    XE6 FMX之控件绘制与显示
    Delphi Android程序启动过程
    Delphi中的容器类
    接口
    集合
    class methed
  • 原文地址:https://www.cnblogs.com/softidea/p/12613969.html
Copyright © 2011-2022 走看看