From 012235d05d8dc7c2decdc7229d93033b0399ecbb Mon Sep 17 00:00:00 2001
From: xiejun <xiejun@vci-tech.com>
Date: 星期日, 10 十一月 2024 15:49:53 +0800
Subject: [PATCH] 集成获取mdm分发通用数据格式接口集成
---
Source/BladeX-Tool/blade-core-tool/src/main/java/org/springblade/core/tool/utils/Func.java | 2156 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 2,156 insertions(+), 0 deletions(-)
diff --git a/Source/BladeX-Tool/blade-core-tool/src/main/java/org/springblade/core/tool/utils/Func.java b/Source/BladeX-Tool/blade-core-tool/src/main/java/org/springblade/core/tool/utils/Func.java
new file mode 100644
index 0000000..e6cac27
--- /dev/null
+++ b/Source/BladeX-Tool/blade-core-tool/src/main/java/org/springblade/core/tool/utils/Func.java
@@ -0,0 +1,2156 @@
+/*
+ * Copyright (c) 2018-2028, DreamLu All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of the dreamlu.net developer nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * Author: DreamLu 鍗㈡槬姊� (596392912@qq.com)
+ */
+package org.springblade.core.tool.utils;
+
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.JsonNode;
+import org.springblade.core.tool.jackson.JsonUtil;
+import org.springframework.beans.BeansException;
+import org.springframework.core.MethodParameter;
+import org.springframework.core.annotation.AnnotatedElementUtils;
+import org.springframework.core.convert.TypeDescriptor;
+import org.springframework.lang.Nullable;
+import org.springframework.util.PatternMatchUtils;
+import org.springframework.util.StringUtils;
+import org.springframework.web.method.HandlerMethod;
+
+import java.io.Closeable;
+import java.io.File;
+import java.io.InputStream;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.AnnotatedElement;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+import java.nio.charset.Charset;
+import java.text.DecimalFormat;
+import java.time.Duration;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.time.format.DateTimeFormatter;
+import java.time.temporal.Temporal;
+import java.time.temporal.TemporalAccessor;
+import java.util.*;
+import java.util.function.Supplier;
+
+/**
+ * 宸ュ叿鍖呴泦鍚堬紝宸ュ叿绫诲揩鎹锋柟寮�
+ *
+ * @author L.cm
+ */
+public class Func {
+
+ /**
+ * 鏂█锛屽繀椤讳笉鑳戒负 null
+ * <blockquote><pre>
+ * public Foo(Bar bar) {
+ * this.bar = $.requireNotNull(bar);
+ * }
+ * </pre></blockquote>
+ *
+ * @param obj the object reference to check for nullity
+ * @param <T> the type of the reference
+ * @return {@code obj} if not {@code null}
+ * @throws NullPointerException if {@code obj} is {@code null}
+ */
+ public static <T> T requireNotNull(T obj) {
+ return Objects.requireNonNull(obj);
+ }
+
+ /**
+ * 鏂█锛屽繀椤讳笉鑳戒负 null
+ * <blockquote><pre>
+ * public Foo(Bar bar, Baz baz) {
+ * this.bar = $.requireNotNull(bar, "bar must not be null");
+ * this.baz = $.requireNotNull(baz, "baz must not be null");
+ * }
+ * </pre></blockquote>
+ *
+ * @param obj the object reference to check for nullity
+ * @param message detail message to be used in the event that a {@code
+ * NullPointerException} is thrown
+ * @param <T> the type of the reference
+ * @return {@code obj} if not {@code null}
+ * @throws NullPointerException if {@code obj} is {@code null}
+ */
+ public static <T> T requireNotNull(T obj, String message) {
+ return Objects.requireNonNull(obj, message);
+ }
+
+ /**
+ * 鏂█锛屽繀椤讳笉鑳戒负 null
+ * <blockquote><pre>
+ * public Foo(Bar bar, Baz baz) {
+ * this.bar = $.requireNotNull(bar, () -> "bar must not be null");
+ * }
+ * </pre></blockquote>
+ *
+ * @param obj the object reference to check for nullity
+ * @param messageSupplier supplier of the detail message to be
+ * used in the event that a {@code NullPointerException} is thrown
+ * @param <T> the type of the reference
+ * @return {@code obj} if not {@code null}
+ * @throws NullPointerException if {@code obj} is {@code null}
+ */
+ public static <T> T requireNotNull(T obj, Supplier<String> messageSupplier) {
+ return Objects.requireNonNull(obj, messageSupplier);
+ }
+
+ /**
+ * 鍒ゆ柇瀵硅薄鏄惁涓簄ull
+ * <p>
+ * This method exists to be used as a
+ * {@link java.util.function.Predicate}, {@code filter($::isNull)}
+ * </p>
+ *
+ * @param obj a reference to be checked against {@code null}
+ * @return {@code true} if the provided reference is {@code null} otherwise
+ * {@code false}
+ * @see java.util.function.Predicate
+ */
+ public static boolean isNull(@Nullable Object obj) {
+ return Objects.isNull(obj);
+ }
+
+ /**
+ * 鍒ゆ柇瀵硅薄鏄惁 not null
+ * <p>
+ * This method exists to be used as a
+ * {@link java.util.function.Predicate}, {@code filter($::notNull)}
+ * </p>
+ *
+ * @param obj a reference to be checked against {@code null}
+ * @return {@code true} if the provided reference is non-{@code null}
+ * otherwise {@code false}
+ * @see java.util.function.Predicate
+ */
+ public static boolean notNull(@Nullable Object obj) {
+ return Objects.nonNull(obj);
+ }
+
+ /**
+ * 棣栧瓧姣嶅彉灏忓啓
+ *
+ * @param str 瀛楃涓�
+ * @return {String}
+ */
+ public static String firstCharToLower(String str) {
+ return StringUtil.firstCharToLower(str);
+ }
+
+ /**
+ * 棣栧瓧姣嶅彉澶у啓
+ *
+ * @param str 瀛楃涓�
+ * @return {String}
+ */
+ public static String firstCharToUpper(String str) {
+ return StringUtil.firstCharToUpper(str);
+ }
+
+ /**
+ * 鍒ゆ柇鏄惁涓虹┖瀛楃涓�
+ * <pre class="code">
+ * $.isBlank(null) = true
+ * $.isBlank("") = true
+ * $.isBlank(" ") = true
+ * $.isBlank("12345") = false
+ * $.isBlank(" 12345 ") = false
+ * </pre>
+ *
+ * @param cs the {@code CharSequence} to check (may be {@code null})
+ * @return {@code true} if the {@code CharSequence} is not {@code null},
+ * its length is greater than 0, and it does not contain whitespace only
+ * @see Character#isWhitespace
+ */
+ public static boolean isBlank(@Nullable final CharSequence cs) {
+ return StringUtil.isBlank(cs);
+ }
+
+ /**
+ * 鍒ゆ柇涓嶄负绌哄瓧绗︿覆
+ * <pre>
+ * $.isNotBlank(null) = false
+ * $.isNotBlank("") = false
+ * $.isNotBlank(" ") = false
+ * $.isNotBlank("bob") = true
+ * $.isNotBlank(" bob ") = true
+ * </pre>
+ *
+ * @param cs the CharSequence to check, may be null
+ * @return {@code true} if the CharSequence is
+ * not empty and not null and not whitespace
+ * @see Character#isWhitespace
+ */
+ public static boolean isNotBlank(@Nullable final CharSequence cs) {
+ return StringUtil.isNotBlank(cs);
+ }
+
+ /**
+ * 鍒ゆ柇鏄惁鏈変换鎰忎竴涓� 绌哄瓧绗︿覆
+ *
+ * @param css CharSequence
+ * @return boolean
+ */
+ public static boolean isAnyBlank(final CharSequence... css) {
+ return StringUtil.isAnyBlank(css);
+ }
+
+ /**
+ * 鍒ゆ柇鏄惁鍏ㄤ负闈炵┖瀛楃涓�
+ *
+ * @param css CharSequence
+ * @return boolean
+ */
+ public static boolean isNoneBlank(final CharSequence... css) {
+ return StringUtil.isNoneBlank(css);
+ }
+
+ /**
+ * 鍒ゆ柇瀵硅薄鏄暟缁�
+ *
+ * @param obj the object to check
+ * @return 鏄惁鏁扮粍
+ */
+ public static boolean isArray(@Nullable Object obj) {
+ return ObjectUtil.isArray(obj);
+ }
+
+ /**
+ * 鍒ゆ柇绌哄璞� object銆乵ap銆乴ist銆乻et銆佸瓧绗︿覆銆佹暟缁�
+ *
+ * @param obj the object to check
+ * @return 鏁扮粍鏄惁涓虹┖
+ */
+ public static boolean isEmpty(@Nullable Object obj) {
+ return ObjectUtil.isEmpty(obj);
+ }
+
+ /**
+ * 瀵硅薄涓嶄负绌� object銆乵ap銆乴ist銆乻et銆佸瓧绗︿覆銆佹暟缁�
+ *
+ * @param obj the object to check
+ * @return 鏄惁涓嶄负绌�
+ */
+ public static boolean isNotEmpty(@Nullable Object obj) {
+ return !ObjectUtil.isEmpty(obj);
+ }
+
+ /**
+ * 鍒ゆ柇鏁扮粍涓虹┖
+ *
+ * @param array the array to check
+ * @return 鏁扮粍鏄惁涓虹┖
+ */
+ public static boolean isEmpty(@Nullable Object[] array) {
+ return ObjectUtil.isEmpty(array);
+ }
+
+ /**
+ * 鍒ゆ柇鏁扮粍涓嶄负绌�
+ *
+ * @param array 鏁扮粍
+ * @return 鏁扮粍鏄惁涓嶄负绌�
+ */
+ public static boolean isNotEmpty(@Nullable Object[] array) {
+ return ObjectUtil.isNotEmpty(array);
+ }
+
+ /**
+ * 瀵硅薄缁勪腑鏄惁瀛樺湪 Empty Object
+ *
+ * @param os 瀵硅薄缁�
+ * @return boolean
+ */
+ public static boolean hasEmpty(Object... os) {
+ for (Object o : os) {
+ if (isEmpty(o)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * 瀵硅薄缁勪腑鏄惁鍏ㄩ儴涓� Empty Object
+ *
+ * @param os 瀵硅薄缁�
+ * @return boolean
+ */
+ public static boolean isAllEmpty(Object... os) {
+ for (Object o : os) {
+ if (isNotEmpty(o)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * 灏嗗瓧绗︿覆涓壒瀹氭ā寮忕殑瀛楃杞崲鎴恗ap涓搴旂殑鍊�
+ * <p>
+ * use: format("my name is ${name}, and i like ${like}!", {"name":"L.cm", "like": "Java"})
+ *
+ * @param message 闇�瑕佽浆鎹㈢殑瀛楃涓�
+ * @param params 杞崲鎵�闇�鐨勯敭鍊煎闆嗗悎
+ * @return 杞崲鍚庣殑瀛楃涓�
+ */
+ public static String format(@Nullable String message, @Nullable Map<String, ?> params) {
+ return StringUtil.format(message, params);
+ }
+
+ /**
+ * 鍚� log 鏍煎紡鐨� format 瑙勫垯
+ * <p>
+ * use: format("my name is {}, and i like {}!", "L.cm", "Java")
+ *
+ * @param message 闇�瑕佽浆鎹㈢殑瀛楃涓�
+ * @param arguments 闇�瑕佹浛鎹㈢殑鍙橀噺
+ * @return 杞崲鍚庣殑瀛楃涓�
+ */
+ public static String format(@Nullable String message, @Nullable Object... arguments) {
+ return StringUtil.format(message, arguments);
+ }
+
+ /**
+ * 鏍煎紡鍖栨墽琛屾椂闂达紝鍗曚綅涓� ms 鍜� s锛屼繚鐣欎笁浣嶅皬鏁�
+ *
+ * @param nanos 绾崇
+ * @return 鏍煎紡鍖栧悗鐨勬椂闂�
+ */
+ public static String format(long nanos) {
+ return StringUtil.format(nanos);
+ }
+
+ /**
+ * 姣旇緝涓や釜瀵硅薄鏄惁鐩哥瓑銆�<br>
+ * 鐩稿悓鐨勬潯浠舵湁涓や釜锛屾弧瓒冲叾涓�鍗冲彲锛�<br>
+ *
+ * @param obj1 瀵硅薄1
+ * @param obj2 瀵硅薄2
+ * @return 鏄惁鐩哥瓑
+ */
+ public static boolean equals(Object obj1, Object obj2) {
+ return Objects.equals(obj1, obj2);
+ }
+
+ /**
+ * 瀹夊叏鐨� equals
+ *
+ * @param o1 first Object to compare
+ * @param o2 second Object to compare
+ * @return whether the given objects are equal
+ * @see Object#equals(Object)
+ * @see java.util.Arrays#equals
+ */
+ public static boolean equalsSafe(@Nullable Object o1, @Nullable Object o2) {
+ return ObjectUtil.nullSafeEquals(o1, o2);
+ }
+
+ /**
+ * 鍒ゆ柇鏁扮粍涓槸鍚﹀寘鍚厓绱�
+ *
+ * @param array the Array to check
+ * @param element the element to look for
+ * @param <T> The generic tag
+ * @return {@code true} if found, {@code false} else
+ */
+ public static <T> boolean contains(@Nullable T[] array, final T element) {
+ return CollectionUtil.contains(array, element);
+ }
+
+ /**
+ * 鍒ゆ柇杩唬鍣ㄤ腑鏄惁鍖呭惈鍏冪礌
+ *
+ * @param iterator the Iterator to check
+ * @param element the element to look for
+ * @return {@code true} if found, {@code false} otherwise
+ */
+ public static boolean contains(@Nullable Iterator<?> iterator, Object element) {
+ return CollectionUtil.contains(iterator, element);
+ }
+
+ /**
+ * 鍒ゆ柇鏋氫妇鏄惁鍖呭惈璇ュ厓绱�
+ *
+ * @param enumeration the Enumeration to check
+ * @param element the element to look for
+ * @return {@code true} if found, {@code false} otherwise
+ */
+ public static boolean contains(@Nullable Enumeration<?> enumeration, Object element) {
+ return CollectionUtil.contains(enumeration, element);
+ }
+
+ /**
+ * 涓嶅彲鍙� Set
+ *
+ * @param es 瀵硅薄
+ * @param <E> 娉涘瀷
+ * @return 闆嗗悎
+ */
+ @SafeVarargs
+ public static <E> Set<E> ofImmutableSet(E... es) {
+ return CollectionUtil.ofImmutableSet(es);
+ }
+
+ /**
+ * 涓嶅彲鍙� List
+ *
+ * @param es 瀵硅薄
+ * @param <E> 娉涘瀷
+ * @return 闆嗗悎
+ */
+ @SafeVarargs
+ public static <E> List<E> ofImmutableList(E... es) {
+ return CollectionUtil.ofImmutableList(es);
+ }
+
+ /**
+ * 寮鸿浆string,骞跺幓鎺夊浣欑┖鏍�
+ *
+ * @param str 瀛楃涓�
+ * @return {String}
+ */
+ public static String toStr(Object str) {
+ return toStr(str, "");
+ }
+
+ /**
+ * 寮鸿浆string,骞跺幓鎺夊浣欑┖鏍�
+ *
+ * @param str 瀛楃涓�
+ * @param defaultValue 榛樿鍊�
+ * @return {String}
+ */
+ public static String toStr(Object str, String defaultValue) {
+ if (null == str || str.equals(StringPool.NULL)) {
+ return defaultValue;
+ }
+ return String.valueOf(str);
+ }
+
+ /**
+ * 寮鸿浆string(鍖呭惈绌哄瓧绗︿覆),骞跺幓鎺夊浣欑┖鏍�
+ *
+ * @param str 瀛楃涓�
+ * @param defaultValue 榛樿鍊�
+ * @return {String}
+ */
+ public static String toStrWithEmpty(Object str, String defaultValue) {
+ if (null == str || str.equals(StringPool.NULL) || str.equals(StringPool.EMPTY)) {
+ return defaultValue;
+ }
+ return String.valueOf(str);
+ }
+
+
+ /**
+ * 鍒ゆ柇涓�涓瓧绗︿覆鏄惁鏄暟瀛�
+ *
+ * @param cs the CharSequence to check, may be null
+ * @return {boolean}
+ */
+ public static boolean isNumeric(final CharSequence cs) {
+ return StringUtil.isNumeric(cs);
+ }
+
+ /**
+ * 瀛楃涓茶浆 int锛屼负绌哄垯杩斿洖0
+ *
+ * <pre>
+ * $.toInt(null) = 0
+ * $.toInt("") = 0
+ * $.toInt("1") = 1
+ * </pre>
+ *
+ * @param str the string to convert, may be null
+ * @return the int represented by the string, or <code>zero</code> if
+ * conversion fails
+ */
+ public static int toInt(final Object str) {
+ return NumberUtil.toInt(String.valueOf(str));
+ }
+
+ /**
+ * 瀛楃涓茶浆 int锛屼负绌哄垯杩斿洖榛樿鍊�
+ *
+ * <pre>
+ * $.toInt(null, 1) = 1
+ * $.toInt("", 1) = 1
+ * $.toInt("1", 0) = 1
+ * </pre>
+ *
+ * @param str the string to convert, may be null
+ * @param defaultValue the default value
+ * @return the int represented by the string, or the default if conversion fails
+ */
+ public static int toInt(@Nullable final Object str, final int defaultValue) {
+ return NumberUtil.toInt(String.valueOf(str), defaultValue);
+ }
+
+ /**
+ * 瀛楃涓茶浆 long锛屼负绌哄垯杩斿洖0
+ *
+ * <pre>
+ * $.toLong(null) = 0L
+ * $.toLong("") = 0L
+ * $.toLong("1") = 1L
+ * </pre>
+ *
+ * @param str the string to convert, may be null
+ * @return the long represented by the string, or <code>0</code> if
+ * conversion fails
+ */
+ public static long toLong(final Object str) {
+ return NumberUtil.toLong(String.valueOf(str));
+ }
+
+ /**
+ * 瀛楃涓茶浆 long锛屼负绌哄垯杩斿洖榛樿鍊�
+ *
+ * <pre>
+ * $.toLong(null, 1L) = 1L
+ * $.toLong("", 1L) = 1L
+ * $.toLong("1", 0L) = 1L
+ * </pre>
+ *
+ * @param str the string to convert, may be null
+ * @param defaultValue the default value
+ * @return the long represented by the string, or the default if conversion fails
+ */
+ public static long toLong(@Nullable final Object str, final long defaultValue) {
+ return NumberUtil.toLong(String.valueOf(str), defaultValue);
+ }
+
+ /**
+ * <p>Convert a <code>String</code> to an <code>Double</code>, returning a
+ * default value if the conversion fails.</p>
+ *
+ * <p>If the string is <code>null</code>, the default value is returned.</p>
+ *
+ * <pre>
+ * $.toDouble(null, 1) = 1.0
+ * $.toDouble("", 1) = 1.0
+ * $.toDouble("1", 0) = 1.0
+ * </pre>
+ *
+ * @param value the string to convert, may be null
+ * @return the int represented by the string, or the default if conversion fails
+ */
+ public static Double toDouble(Object value) {
+ return toDouble(String.valueOf(value), -1.00);
+ }
+
+ /**
+ * <p>Convert a <code>String</code> to an <code>Double</code>, returning a
+ * default value if the conversion fails.</p>
+ *
+ * <p>If the string is <code>null</code>, the default value is returned.</p>
+ *
+ * <pre>
+ * $.toDouble(null, 1) = 1.0
+ * $.toDouble("", 1) = 1.0
+ * $.toDouble("1", 0) = 1.0
+ * </pre>
+ *
+ * @param value the string to convert, may be null
+ * @param defaultValue the default value
+ * @return the int represented by the string, or the default if conversion fails
+ */
+ public static Double toDouble(Object value, Double defaultValue) {
+ return NumberUtil.toDouble(String.valueOf(value), defaultValue);
+ }
+
+ /**
+ * <p>Convert a <code>String</code> to an <code>Float</code>, returning a
+ * default value if the conversion fails.</p>
+ *
+ * <p>If the string is <code>null</code>, the default value is returned.</p>
+ *
+ * <pre>
+ * $.toFloat(null, 1) = 1.00f
+ * $.toFloat("", 1) = 1.00f
+ * $.toFloat("1", 0) = 1.00f
+ * </pre>
+ *
+ * @param value the string to convert, may be null
+ * @return the int represented by the string, or the default if conversion fails
+ */
+ public static Float toFloat(Object value) {
+ return toFloat(String.valueOf(value), -1.0f);
+ }
+
+ /**
+ * <p>Convert a <code>String</code> to an <code>Float</code>, returning a
+ * default value if the conversion fails.</p>
+ *
+ * <p>If the string is <code>null</code>, the default value is returned.</p>
+ *
+ * <pre>
+ * $.toFloat(null, 1) = 1.00f
+ * $.toFloat("", 1) = 1.00f
+ * $.toFloat("1", 0) = 1.00f
+ * </pre>
+ *
+ * @param value the string to convert, may be null
+ * @param defaultValue the default value
+ * @return the int represented by the string, or the default if conversion fails
+ */
+ public static Float toFloat(Object value, Float defaultValue) {
+ return NumberUtil.toFloat(String.valueOf(value), defaultValue);
+ }
+
+ /**
+ * <p>Convert a <code>String</code> to an <code>Boolean</code>, returning a
+ * default value if the conversion fails.</p>
+ *
+ * <p>If the string is <code>null</code>, the default value is returned.</p>
+ *
+ * <pre>
+ * $.toBoolean("true", true) = true
+ * $.toBoolean("false") = false
+ * $.toBoolean("", false) = false
+ * </pre>
+ *
+ * @param value the string to convert, may be null
+ * @return the int represented by the string, or the default if conversion fails
+ */
+ public static Boolean toBoolean(Object value) {
+ return toBoolean(value, null);
+ }
+
+ /**
+ * <p>Convert a <code>String</code> to an <code>Boolean</code>, returning a
+ * default value if the conversion fails.</p>
+ *
+ * <p>If the string is <code>null</code>, the default value is returned.</p>
+ *
+ * <pre>
+ * $.toBoolean("true", true) = true
+ * $.toBoolean("false") = false
+ * $.toBoolean("", false) = false
+ * </pre>
+ *
+ * @param value the string to convert, may be null
+ * @param defaultValue the default value
+ * @return the int represented by the string, or the default if conversion fails
+ */
+ public static Boolean toBoolean(Object value, Boolean defaultValue) {
+ if (value != null) {
+ String val = String.valueOf(value);
+ val = val.toLowerCase().trim();
+ return Boolean.parseBoolean(val);
+ }
+ return defaultValue;
+ }
+
+ /**
+ * 杞崲涓篒nteger鏁扮粍<br>
+ *
+ * @param str 琚浆鎹㈢殑鍊�
+ * @return 缁撴灉
+ */
+ public static Integer[] toIntArray(String str) {
+ return toIntArray(",", str);
+ }
+
+ /**
+ * 杞崲涓篒nteger鏁扮粍<br>
+ *
+ * @param split 鍒嗛殧绗�
+ * @param str 琚浆鎹㈢殑鍊�
+ * @return 缁撴灉
+ */
+ public static Integer[] toIntArray(String split, String str) {
+ if (StringUtil.isEmpty(str)) {
+ return new Integer[]{};
+ }
+ String[] arr = str.split(split);
+ final Integer[] ints = new Integer[arr.length];
+ for (int i = 0; i < arr.length; i++) {
+ final Integer v = toInt(arr[i], 0);
+ ints[i] = v;
+ }
+ return ints;
+ }
+
+ /**
+ * 杞崲涓篒nteger闆嗗悎<br>
+ *
+ * @param str 缁撴灉琚浆鎹㈢殑鍊�
+ * @return 缁撴灉
+ */
+ public static List<Integer> toIntList(String str) {
+ return Arrays.asList(toIntArray(str));
+ }
+
+ /**
+ * 杞崲涓篒nteger闆嗗悎<br>
+ *
+ * @param split 鍒嗛殧绗�
+ * @param str 琚浆鎹㈢殑鍊�
+ * @return 缁撴灉
+ */
+ public static List<Integer> toIntList(String split, String str) {
+ return Arrays.asList(toIntArray(split, str));
+ }
+
+ /**
+ * 鑾峰彇绗竴浣岻nteger鏁板��
+ *
+ * @param str 琚浆鎹㈢殑鍊�
+ * @return 缁撴灉
+ */
+ public static Integer firstInt(String str) {
+ return firstInt(",", str);
+ }
+
+ /**
+ * 鑾峰彇绗竴浣岻nteger鏁板��
+ *
+ * @param split 鍒嗛殧绗�
+ * @param str 琚浆鎹㈢殑鍊�
+ * @return 缁撴灉
+ */
+ public static Integer firstInt(String split, String str) {
+ List<Integer> ints = toIntList(split, str);
+ if (isEmpty(ints)) {
+ return null;
+ } else {
+ return ints.get(0);
+ }
+ }
+
+ /**
+ * 杞崲涓篖ong鏁扮粍<br>
+ *
+ * @param str 琚浆鎹㈢殑鍊�
+ * @return 缁撴灉
+ */
+ public static Long[] toLongArray(String str) {
+ return toLongArray(",", str);
+ }
+
+ /**
+ * 杞崲涓篖ong鏁扮粍<br>
+ *
+ * @param split 鍒嗛殧绗�
+ * @param str 琚浆鎹㈢殑鍊�
+ * @return 缁撴灉
+ */
+ public static Long[] toLongArray(String split, String str) {
+ if (StringUtil.isEmpty(str)) {
+ return new Long[]{};
+ }
+ String[] arr = str.split(split);
+ final Long[] longs = new Long[arr.length];
+ for (int i = 0; i < arr.length; i++) {
+ final Long v = toLong(arr[i], 0);
+ longs[i] = v;
+ }
+ return longs;
+ }
+
+ /**
+ * 杞崲涓篖ong闆嗗悎<br>
+ *
+ * @param str 缁撴灉琚浆鎹㈢殑鍊�
+ * @return 缁撴灉
+ */
+ public static List<Long> toLongList(String str) {
+ return Arrays.asList(toLongArray(str));
+ }
+
+ /**
+ * 杞崲涓篖ong闆嗗悎<br>
+ *
+ * @param split 鍒嗛殧绗�
+ * @param str 琚浆鎹㈢殑鍊�
+ * @return 缁撴灉
+ */
+ public static List<Long> toLongList(String split, String str) {
+ return Arrays.asList(toLongArray(split, str));
+ }
+
+ /**
+ * 鑾峰彇绗竴浣峀ong鏁板��
+ *
+ * @param str 琚浆鎹㈢殑鍊�
+ * @return 缁撴灉
+ */
+ public static Long firstLong(String str) {
+ return firstLong(",", str);
+ }
+
+ /**
+ * 鑾峰彇绗竴浣峀ong鏁板��
+ *
+ * @param split 鍒嗛殧绗�
+ * @param str 琚浆鎹㈢殑鍊�
+ * @return 缁撴灉
+ */
+ public static Long firstLong(String split, String str) {
+ List<Long> longs = toLongList(split, str);
+ if (isEmpty(longs)) {
+ return null;
+ } else {
+ return longs.get(0);
+ }
+ }
+
+ /**
+ * 杞崲涓篠tring鏁扮粍<br>
+ *
+ * @param str 琚浆鎹㈢殑鍊�
+ * @return 缁撴灉
+ */
+ public static String[] toStrArray(String str) {
+ return toStrArray(",", str);
+ }
+
+ /**
+ * 杞崲涓篠tring鏁扮粍<br>
+ *
+ * @param split 鍒嗛殧绗�
+ * @param str 琚浆鎹㈢殑鍊�
+ * @return 缁撴灉
+ */
+ public static String[] toStrArray(String split, String str) {
+ if (isBlank(str)) {
+ return new String[]{};
+ }
+ return str.split(split);
+ }
+
+ /**
+ * 杞崲涓篠tring闆嗗悎<br>
+ *
+ * @param str 缁撴灉琚浆鎹㈢殑鍊�
+ * @return 缁撴灉
+ */
+ public static List<String> toStrList(String str) {
+ return Arrays.asList(toStrArray(str));
+ }
+
+ /**
+ * 杞崲涓篠tring闆嗗悎<br>
+ *
+ * @param split 鍒嗛殧绗�
+ * @param str 琚浆鎹㈢殑鍊�
+ * @return 缁撴灉
+ */
+ public static List<String> toStrList(String split, String str) {
+ return Arrays.asList(toStrArray(split, str));
+ }
+
+ /**
+ * 鑾峰彇绗竴浣峉tring鏁板��
+ *
+ * @param str 琚浆鎹㈢殑鍊�
+ * @return 缁撴灉
+ */
+ public static String firstStr(String str) {
+ return firstStr(",", str);
+ }
+
+ /**
+ * 鑾峰彇绗竴浣峉tring鏁板��
+ *
+ * @param split 鍒嗛殧绗�
+ * @param str 琚浆鎹㈢殑鍊�
+ * @return 缁撴灉
+ */
+ public static String firstStr(String split, String str) {
+ List<String> strs = toStrList(split, str);
+ if (isEmpty(strs)) {
+ return null;
+ } else {
+ return strs.get(0);
+ }
+ }
+
+ /**
+ * 灏� long 杞煭瀛楃涓� 涓� 62 杩涘埗
+ *
+ * @param num 鏁板瓧
+ * @return 鐭瓧绗︿覆
+ */
+ public static String to62String(long num) {
+ return NumberUtil.to62String(num);
+ }
+
+ /**
+ * 灏嗛泦鍚堟嫾鎺ユ垚瀛楃涓诧紝榛樿浣跨敤`,`鎷兼帴
+ *
+ * @param coll the {@code Collection} to convert
+ * @return the delimited {@code String}
+ */
+ public static String join(Collection<?> coll) {
+ return StringUtil.join(coll);
+ }
+
+ /**
+ * 灏嗛泦鍚堟嫾鎺ユ垚瀛楃涓诧紝榛樿鎸囧畾鍒嗛殧绗�
+ *
+ * @param coll the {@code Collection} to convert
+ * @param delim the delimiter to use (typically a ",")
+ * @return the delimited {@code String}
+ */
+ public static String join(Collection<?> coll, String delim) {
+ return StringUtil.join(coll, delim);
+ }
+
+ /**
+ * 灏嗘暟缁勬嫾鎺ユ垚瀛楃涓诧紝榛樿浣跨敤`,`鎷兼帴
+ *
+ * @param arr the array to display
+ * @return the delimited {@code String}
+ */
+ public static String join(Object[] arr) {
+ return StringUtil.join(arr);
+ }
+
+ /**
+ * 灏嗘暟缁勬嫾鎺ユ垚瀛楃涓诧紝榛樿鎸囧畾鍒嗛殧绗�
+ *
+ * @param arr the array to display
+ * @param delim the delimiter to use (typically a ",")
+ * @return the delimited {@code String}
+ */
+ public static String join(Object[] arr, String delim) {
+ return StringUtil.join(arr, delim);
+ }
+
+ /**
+ * 鍒囧垎瀛楃涓诧紝涓嶅幓闄ゅ垏鍒嗗悗姣忎釜鍏冪礌涓よ竟鐨勭┖鐧界锛屼笉鍘婚櫎绌虹櫧椤�
+ *
+ * @param str 琚垏鍒嗙殑瀛楃涓�
+ * @param separator 鍒嗛殧绗﹀瓧绗�
+ * @return 鍒囧垎鍚庣殑闆嗗悎
+ */
+ public static List<String> split(CharSequence str, char separator) {
+ return StringUtil.split(str, separator, -1);
+ }
+
+ /**
+ * 鍒囧垎瀛楃涓诧紝鍘婚櫎鍒囧垎鍚庢瘡涓厓绱犱袱杈圭殑绌虹櫧绗︼紝鍘婚櫎绌虹櫧椤�
+ *
+ * @param str 琚垏鍒嗙殑瀛楃涓�
+ * @param separator 鍒嗛殧绗﹀瓧绗�
+ * @return 鍒囧垎鍚庣殑闆嗗悎
+ */
+ public static List<String> splitTrim(CharSequence str, char separator) {
+ return StringUtil.splitTrim(str, separator);
+ }
+
+ /**
+ * 鍒囧垎瀛楃涓诧紝鍘婚櫎鍒囧垎鍚庢瘡涓厓绱犱袱杈圭殑绌虹櫧绗︼紝鍘婚櫎绌虹櫧椤�
+ *
+ * @param str 琚垏鍒嗙殑瀛楃涓�
+ * @param separator 鍒嗛殧绗﹀瓧绗�
+ * @return 鍒囧垎鍚庣殑闆嗗悎
+ */
+ public static List<String> splitTrim(CharSequence str, CharSequence separator) {
+ return StringUtil.splitTrim(str, separator);
+ }
+
+ /**
+ * 鍒嗗壊 瀛楃涓�
+ *
+ * @param str 瀛楃涓�
+ * @param delimiter 鍒嗗壊绗�
+ * @return 瀛楃涓叉暟缁�
+ */
+ public static String[] split(@Nullable String str, @Nullable String delimiter) {
+ return StringUtil.delimitedListToStringArray(str, delimiter);
+ }
+
+ /**
+ * 鍒嗗壊 瀛楃涓� 鍒犻櫎甯歌 绌虹櫧绗�
+ *
+ * @param str 瀛楃涓�
+ * @param delimiter 鍒嗗壊绗�
+ * @return 瀛楃涓叉暟缁�
+ */
+ public static String[] splitTrim(@Nullable String str, @Nullable String delimiter) {
+ return StringUtil.delimitedListToStringArray(str, delimiter, " \t\n\n\f");
+ }
+
+ /**
+ * 瀛楃涓叉槸鍚︾鍚堟寚瀹氱殑 琛ㄨ揪寮�
+ *
+ * <p>
+ * pattern styles: "xxx*", "*xxx", "*xxx*" and "xxx*yyy"
+ * </p>
+ *
+ * @param pattern 琛ㄨ揪寮�
+ * @param str 瀛楃涓�
+ * @return 鏄惁鍖归厤
+ */
+ public static boolean simpleMatch(@Nullable String pattern, @Nullable String str) {
+ return PatternMatchUtils.simpleMatch(pattern, str);
+ }
+
+ /**
+ * 瀛楃涓叉槸鍚︾鍚堟寚瀹氱殑 琛ㄨ揪寮�
+ *
+ * <p>
+ * pattern styles: "xxx*", "*xxx", "*xxx*" and "xxx*yyy"
+ * </p>
+ *
+ * @param patterns 琛ㄨ揪寮� 鏁扮粍
+ * @param str 瀛楃涓�
+ * @return 鏄惁鍖归厤
+ */
+ public static boolean simpleMatch(@Nullable String[] patterns, String str) {
+ return PatternMatchUtils.simpleMatch(patterns, str);
+ }
+
+ /**
+ * 鐢熸垚uuid
+ *
+ * @return UUID
+ */
+ public static String randomUUID() {
+ return StringUtil.randomUUID();
+ }
+
+ /**
+ * 杞箟HTML鐢ㄤ簬瀹夊叏杩囨护
+ *
+ * @param html html
+ * @return {String}
+ */
+ public static String escapeHtml(String html) {
+ return StringUtil.escapeHtml(html);
+ }
+
+ /**
+ * 闅忔満鏁扮敓鎴�
+ *
+ * @param count 瀛楃闀垮害
+ * @return 闅忔満鏁�
+ */
+ public static String random(int count) {
+ return StringUtil.random(count);
+ }
+
+ /**
+ * 闅忔満鏁扮敓鎴�
+ *
+ * @param count 瀛楃闀垮害
+ * @param randomType 闅忔満鏁扮被鍒�
+ * @return 闅忔満鏁�
+ */
+ public static String random(int count, RandomType randomType) {
+ return StringUtil.random(count, randomType);
+ }
+
+ /**
+ * 瀛楃涓插簭鍒楀寲鎴� md5
+ *
+ * @param data Data to digest
+ * @return MD5 digest as a hex string
+ */
+ public static String md5Hex(final String data) {
+ return DigestUtil.md5Hex(data);
+ }
+
+ /**
+ * 鏁扮粍搴忓垪鍖栨垚 md5
+ *
+ * @param bytes the bytes to calculate the digest over
+ * @return md5 digest string
+ */
+ public static String md5Hex(final byte[] bytes) {
+ return DigestUtil.md5Hex(bytes);
+ }
+
+
+ /**
+ * sha1Hex
+ *
+ * @param data Data to digest
+ * @return digest as a hex string
+ */
+ public static String sha1Hex(String data) {
+ return DigestUtil.sha1Hex(data);
+ }
+
+ /**
+ * sha1Hex
+ *
+ * @param bytes Data to digest
+ * @return digest as a hex string
+ */
+ public static String sha1Hex(final byte[] bytes) {
+ return DigestUtil.sha1Hex(bytes);
+ }
+
+ /**
+ * SHA224Hex
+ *
+ * @param data Data to digest
+ * @return digest as a hex string
+ */
+ public static String sha224Hex(String data) {
+ return DigestUtil.sha224Hex(data);
+ }
+
+ /**
+ * SHA224Hex
+ *
+ * @param bytes Data to digest
+ * @return digest as a hex string
+ */
+ public static String sha224Hex(final byte[] bytes) {
+ return DigestUtil.sha224Hex(bytes);
+ }
+
+ /**
+ * sha256Hex
+ *
+ * @param data Data to digest
+ * @return digest as a hex string
+ */
+ public static String sha256Hex(String data) {
+ return DigestUtil.sha256Hex(data);
+ }
+
+ /**
+ * sha256Hex
+ *
+ * @param bytes Data to digest
+ * @return digest as a hex string
+ */
+ public static String sha256Hex(final byte[] bytes) {
+ return DigestUtil.sha256Hex(bytes);
+ }
+
+ /**
+ * sha384Hex
+ *
+ * @param data Data to digest
+ * @return digest as a hex string
+ */
+ public static String sha384Hex(String data) {
+ return DigestUtil.sha384Hex(data);
+ }
+
+ /**
+ * sha384Hex
+ *
+ * @param bytes Data to digest
+ * @return digest as a hex string
+ */
+ public static String sha384Hex(final byte[] bytes) {
+ return DigestUtil.sha384Hex(bytes);
+ }
+
+ /**
+ * sha512Hex
+ *
+ * @param data Data to digest
+ * @return digest as a hex string
+ */
+ public static String sha512Hex(String data) {
+ return DigestUtil.sha512Hex(data);
+ }
+
+ /**
+ * sha512Hex
+ *
+ * @param bytes Data to digest
+ * @return digest as a hex string
+ */
+ public static String sha512Hex(final byte[] bytes) {
+ return DigestUtil.sha512Hex(bytes);
+ }
+
+ /**
+ * hmacMd5 Hex
+ *
+ * @param data Data to digest
+ * @param key key
+ * @return digest as a hex string
+ */
+ public static String hmacMd5Hex(String data, String key) {
+ return DigestUtil.hmacMd5Hex(data, key);
+ }
+
+ /**
+ * hmacMd5 Hex
+ *
+ * @param bytes Data to digest
+ * @param key key
+ * @return digest as a hex string
+ */
+ public static String hmacMd5Hex(final byte[] bytes, String key) {
+ return DigestUtil.hmacMd5Hex(bytes, key);
+ }
+
+ /**
+ * hmacSha1 Hex
+ *
+ * @param data Data to digest
+ * @param key key
+ * @return digest as a hex string
+ */
+ public static String hmacSha1Hex(String data, String key) {
+ return DigestUtil.hmacSha1Hex(data, key);
+ }
+
+ /**
+ * hmacSha1 Hex
+ *
+ * @param bytes Data to digest
+ * @param key key
+ * @return digest as a hex string
+ */
+ public static String hmacSha1Hex(final byte[] bytes, String key) {
+ return DigestUtil.hmacSha1Hex(bytes, key);
+ }
+
+ /**
+ * hmacSha224 Hex
+ *
+ * @param data Data to digest
+ * @param key key
+ * @return digest as a hex string
+ */
+ public static String hmacSha224Hex(String data, String key) {
+ return DigestUtil.hmacSha224Hex(data, key);
+ }
+
+ /**
+ * hmacSha224 Hex
+ *
+ * @param bytes Data to digest
+ * @param key key
+ * @return digest as a hex string
+ */
+ public static String hmacSha224Hex(final byte[] bytes, String key) {
+ return DigestUtil.hmacSha224Hex(bytes, key);
+ }
+
+ /**
+ * hmacSha256 Hex
+ *
+ * @param data Data to digest
+ * @param key key
+ * @return digest as a hex string
+ */
+ public static String hmacSha256Hex(String data, String key) {
+ return DigestUtil.hmacSha256Hex(data, key);
+ }
+
+ /**
+ * hmacSha256 Hex
+ *
+ * @param bytes Data to digest
+ * @param key key
+ * @return digest as a hex string
+ */
+ public static String hmacSha256Hex(final byte[] bytes, String key) {
+ return DigestUtil.hmacSha256Hex(bytes, key);
+ }
+
+ /**
+ * hmacSha384 Hex
+ *
+ * @param data Data to digest
+ * @param key key
+ * @return digest as a hex string
+ */
+ public static String hmacSha384Hex(String data, String key) {
+ return DigestUtil.hmacSha384Hex(data, key);
+ }
+
+ /**
+ * hmacSha384 Hex
+ *
+ * @param bytes Data to digest
+ * @param key key
+ * @return digest as a hex string
+ */
+ public static String hmacSha384Hex(final byte[] bytes, String key) {
+ return DigestUtil.hmacSha384Hex(bytes, key);
+ }
+
+ /**
+ * hmacSha512 Hex
+ *
+ * @param data Data to digest
+ * @param key key
+ * @return digest as a hex string
+ */
+ public static String hmacSha512Hex(String data, String key) {
+ return DigestUtil.hmacSha512Hex(data, key);
+ }
+
+ /**
+ * hmacSha512 Hex
+ *
+ * @param bytes Data to digest
+ * @param key key
+ * @return digest as a hex string
+ */
+ public static String hmacSha512Hex(final byte[] bytes, String key) {
+ return DigestUtil.hmacSha512Hex(bytes, key);
+ }
+
+ /**
+ * byte 鏁扮粍搴忓垪鍖栨垚 hex
+ *
+ * @param bytes bytes to encode
+ * @return MD5 digest as a hex string
+ */
+ public static String encodeHex(byte[] bytes) {
+ return DigestUtil.encodeHex(bytes);
+ }
+
+ /**
+ * 瀛楃涓插弽搴忓垪鍖栨垚 hex
+ *
+ * @param hexString String to decode
+ * @return MD5 digest as a hex string
+ */
+ public static byte[] decodeHex(final String hexString) {
+ return DigestUtil.decodeHex(hexString);
+ }
+
+ /**
+ * Base64缂栫爜
+ *
+ * @param value 瀛楃涓�
+ * @return {String}
+ */
+ public static String encodeBase64(String value) {
+ return Base64Util.encode(value);
+ }
+
+ /**
+ * Base64缂栫爜
+ *
+ * @param value 瀛楃涓�
+ * @param charset 瀛楃闆�
+ * @return {String}
+ */
+ public static String encodeBase64(String value, Charset charset) {
+ return Base64Util.encode(value, charset);
+ }
+
+ /**
+ * Base64缂栫爜涓篣RL瀹夊叏
+ *
+ * @param value 瀛楃涓�
+ * @return {String}
+ */
+ public static String encodeBase64UrlSafe(String value) {
+ return Base64Util.encodeUrlSafe(value);
+ }
+
+ /**
+ * Base64缂栫爜涓篣RL瀹夊叏
+ *
+ * @param value 瀛楃涓�
+ * @param charset 瀛楃闆�
+ * @return {String}
+ */
+ public static String encodeBase64UrlSafe(String value, Charset charset) {
+ return Base64Util.encodeUrlSafe(value, charset);
+ }
+
+ /**
+ * Base64瑙g爜
+ *
+ * @param value 瀛楃涓�
+ * @return {String}
+ */
+ public static String decodeBase64(String value) {
+ return Base64Util.decode(value);
+ }
+
+ /**
+ * Base64瑙g爜
+ *
+ * @param value 瀛楃涓�
+ * @param charset 瀛楃闆�
+ * @return {String}
+ */
+ public static String decodeBase64(String value, Charset charset) {
+ return Base64Util.decode(value, charset);
+ }
+
+ /**
+ * Base64URL瀹夊叏瑙g爜
+ *
+ * @param value 瀛楃涓�
+ * @return {String}
+ */
+ public static String decodeBase64UrlSafe(String value) {
+ return Base64Util.decodeUrlSafe(value);
+ }
+
+ /**
+ * Base64URL瀹夊叏瑙g爜
+ *
+ * @param value 瀛楃涓�
+ * @param charset 瀛楃闆�
+ * @return {String}
+ */
+ public static String decodeBase64UrlSafe(String value, Charset charset) {
+ return Base64Util.decodeUrlSafe(value, charset);
+ }
+
+ /**
+ * 鍏抽棴 Closeable
+ *
+ * @param closeable 鑷姩鍏抽棴
+ */
+ public static void closeQuietly(@Nullable Closeable closeable) {
+ IoUtil.closeQuietly(closeable);
+ }
+
+ /**
+ * InputStream to String utf-8
+ *
+ * @param input the <code>InputStream</code> to read from
+ * @return the requested String
+ * @throws NullPointerException if the input is null
+ */
+ public static String readToString(InputStream input) {
+ return IoUtil.readToString(input);
+ }
+
+ /**
+ * InputStream to String
+ *
+ * @param input the <code>InputStream</code> to read from
+ * @param charset the <code>Charset</code>
+ * @return the requested String
+ * @throws NullPointerException if the input is null
+ */
+ public static String readToString(@Nullable InputStream input, Charset charset) {
+ return IoUtil.readToString(input, charset);
+ }
+
+ /**
+ * InputStream to bytes 鏁扮粍
+ *
+ * @param input InputStream
+ * @return the requested byte array
+ */
+ public static byte[] readToByteArray(@Nullable InputStream input) {
+ return IoUtil.readToByteArray(input);
+ }
+
+ /**
+ * 璇诲彇鏂囦欢涓哄瓧绗︿覆
+ *
+ * @param file the file to read, must not be {@code null}
+ * @return the file contents, never {@code null}
+ */
+ public static String readToString(final File file) {
+ return FileUtil.readToString(file);
+ }
+
+ /**
+ * 璇诲彇鏂囦欢涓哄瓧绗︿覆
+ *
+ * @param file the file to read, must not be {@code null}
+ * @param encoding the encoding to use, {@code null} means platform default
+ * @return the file contents, never {@code null}
+ */
+ public static String readToString(File file, Charset encoding) {
+ return FileUtil.readToString(file, encoding);
+ }
+
+ /**
+ * 璇诲彇鏂囦欢涓� byte 鏁扮粍
+ *
+ * @param file the file to read, must not be {@code null}
+ * @return the file contents, never {@code null}
+ */
+ public static byte[] readToByteArray(File file) {
+ return FileUtil.readToByteArray(file);
+ }
+
+ /**
+ * 灏嗗璞″簭鍒楀寲鎴恓son瀛楃涓�
+ *
+ * @param object javaBean
+ * @return jsonString json瀛楃涓�
+ */
+ public static String toJson(Object object) {
+ return JsonUtil.toJson(object);
+ }
+
+ /**
+ * 灏嗗璞″簭鍒楀寲鎴� json byte 鏁扮粍
+ *
+ * @param object javaBean
+ * @return jsonString json瀛楃涓�
+ */
+ public static byte[] toJsonAsBytes(Object object) {
+ return JsonUtil.toJsonAsBytes(object);
+ }
+
+ /**
+ * 灏唈son瀛楃涓茶浆鎴� JsonNode
+ *
+ * @param jsonString jsonString
+ * @return jsonString json瀛楃涓�
+ */
+ public static JsonNode readTree(String jsonString) {
+ return JsonUtil.readTree(jsonString);
+ }
+
+ /**
+ * 灏唈son瀛楃涓茶浆鎴� JsonNode
+ *
+ * @param in InputStream
+ * @return jsonString json瀛楃涓�
+ */
+ public static JsonNode readTree(InputStream in) {
+ return JsonUtil.readTree(in);
+ }
+
+ /**
+ * 灏唈son瀛楃涓茶浆鎴� JsonNode
+ *
+ * @param content content
+ * @return jsonString json瀛楃涓�
+ */
+ public static JsonNode readTree(byte[] content) {
+ return JsonUtil.readTree(content);
+ }
+
+ /**
+ * 灏唈son瀛楃涓茶浆鎴� JsonNode
+ *
+ * @param jsonParser JsonParser
+ * @return jsonString json瀛楃涓�
+ */
+ public static JsonNode readTree(JsonParser jsonParser) {
+ return JsonUtil.readTree(jsonParser);
+ }
+
+ /**
+ * 灏唈son byte 鏁扮粍鍙嶅簭鍒楀寲鎴愬璞�
+ *
+ * @param bytes json bytes
+ * @param valueType class
+ * @param <T> T 娉涘瀷鏍囪
+ * @return Bean
+ */
+ public static <T> T readJson(byte[] bytes, Class<T> valueType) {
+ return JsonUtil.parse(bytes, valueType);
+ }
+
+ /**
+ * 灏唈son鍙嶅簭鍒楀寲鎴愬璞�
+ *
+ * @param jsonString jsonString
+ * @param valueType class
+ * @param <T> T 娉涘瀷鏍囪
+ * @return Bean
+ */
+ public static <T> T readJson(String jsonString, Class<T> valueType) {
+ return JsonUtil.parse(jsonString, valueType);
+ }
+
+ /**
+ * 灏唈son鍙嶅簭鍒楀寲鎴愬璞�
+ *
+ * @param in InputStream
+ * @param valueType class
+ * @param <T> T 娉涘瀷鏍囪
+ * @return Bean
+ */
+ public static <T> T readJson(InputStream in, Class<T> valueType) {
+ return JsonUtil.parse(in, valueType);
+ }
+
+ /**
+ * 灏唈son鍙嶅簭鍒楀寲鎴愬璞�
+ *
+ * @param bytes bytes
+ * @param typeReference 娉涘瀷绫诲瀷
+ * @param <T> T 娉涘瀷鏍囪
+ * @return Bean
+ */
+ public static <T> T readJson(byte[] bytes, TypeReference<T> typeReference) {
+ return JsonUtil.parse(bytes, typeReference);
+ }
+
+ /**
+ * 灏唈son鍙嶅簭鍒楀寲鎴愬璞�
+ *
+ * @param jsonString jsonString
+ * @param typeReference 娉涘瀷绫诲瀷
+ * @param <T> T 娉涘瀷鏍囪
+ * @return Bean
+ */
+ public static <T> T readJson(String jsonString, TypeReference<T> typeReference) {
+ return JsonUtil.parse(jsonString, typeReference);
+ }
+
+ /**
+ * 灏唈son鍙嶅簭鍒楀寲鎴愬璞�
+ *
+ * @param in InputStream
+ * @param typeReference 娉涘瀷绫诲瀷
+ * @param <T> T 娉涘瀷鏍囪
+ * @return Bean
+ */
+ public static <T> T readJson(InputStream in, TypeReference<T> typeReference) {
+ return JsonUtil.parse(in, typeReference);
+ }
+
+ /**
+ * url 缂栫爜
+ *
+ * @param source the String to be encoded
+ * @return the encoded String
+ */
+ public static String urlEncode(String source) {
+ return UrlUtil.encode(source, Charsets.UTF_8);
+ }
+
+ /**
+ * url 缂栫爜
+ *
+ * @param source the String to be encoded
+ * @param charset the character encoding to encode to
+ * @return the encoded String
+ */
+ public static String urlEncode(String source, Charset charset) {
+ return UrlUtil.encode(source, charset);
+ }
+
+ /**
+ * url 瑙g爜
+ *
+ * @param source the encoded String
+ * @return the decoded value
+ * @throws IllegalArgumentException when the given source contains invalid encoded sequences
+ * @see StringUtils#uriDecode(String, Charset)
+ * @see java.net.URLDecoder#decode(String, String)
+ */
+ public static String urlDecode(String source) {
+ return StringUtils.uriDecode(source, Charsets.UTF_8);
+ }
+
+ /**
+ * url 瑙g爜
+ *
+ * @param source the encoded String
+ * @param charset the character encoding to use
+ * @return the decoded value
+ * @throws IllegalArgumentException when the given source contains invalid encoded sequences
+ * @see StringUtils#uriDecode(String, Charset)
+ * @see java.net.URLDecoder#decode(String, String)
+ */
+ public static String urlDecode(String source, Charset charset) {
+ return StringUtils.uriDecode(source, charset);
+ }
+
+ /**
+ * 鏃ユ湡鏃堕棿鏍煎紡鍖�
+ *
+ * @param date 鏃堕棿
+ * @return 鏍煎紡鍖栧悗鐨勬椂闂�
+ */
+ public static String formatDateTime(Date date) {
+ return DateUtil.formatDateTime(date);
+ }
+
+ /**
+ * 鏃ユ湡鏍煎紡鍖�
+ *
+ * @param date 鏃堕棿
+ * @return 鏍煎紡鍖栧悗鐨勬椂闂�
+ */
+ public static String formatDate(Date date) {
+ return DateUtil.formatDate(date);
+ }
+
+ /**
+ * 鏃堕棿鏍煎紡鍖�
+ *
+ * @param date 鏃堕棿
+ * @return 鏍煎紡鍖栧悗鐨勬椂闂�
+ */
+ public static String formatTime(Date date) {
+ return DateUtil.formatTime(date);
+ }
+
+ /**
+ * 瀵硅薄鏍煎紡鍖� 鏀寔鏁板瓧锛宒ate锛宩ava8鏃堕棿
+ *
+ * @param object 鏍煎紡鍖栧璞�
+ * @param pattern 琛ㄨ揪寮�
+ * @return 鏍煎紡鍖栧悗鐨勫瓧绗︿覆
+ */
+ public static String format(Object object, String pattern) {
+ if (object instanceof Number) {
+ DecimalFormat decimalFormat = new DecimalFormat(pattern);
+ return decimalFormat.format(object);
+ } else if (object instanceof Date) {
+ return DateUtil.format((Date) object, pattern);
+ } else if (object instanceof TemporalAccessor) {
+ return DateTimeUtil.format((TemporalAccessor) object, pattern);
+ }
+ throw new IllegalArgumentException("鏈敮鎸佺殑瀵硅薄:" + object + ",鏍煎紡:" + object);
+ }
+
+ /**
+ * 灏嗗瓧绗︿覆杞崲涓烘椂闂�
+ *
+ * @param dateStr 鏃堕棿瀛楃涓�
+ * @param pattern 琛ㄨ揪寮�
+ * @return 鏃堕棿
+ */
+ public static Date parseDate(String dateStr, String pattern) {
+ return DateUtil.parse(dateStr, pattern);
+ }
+
+ /**
+ * 灏嗗瓧绗︿覆杞崲涓烘椂闂�
+ *
+ * @param dateStr 鏃堕棿瀛楃涓�
+ * @param format ConcurrentDateFormat
+ * @return 鏃堕棿
+ */
+ public static Date parse(String dateStr, ConcurrentDateFormat format) {
+ return DateUtil.parse(dateStr, format);
+ }
+
+ /**
+ * 鏃ユ湡鏃堕棿鏍煎紡鍖�
+ *
+ * @param temporal 鏃堕棿
+ * @return 鏍煎紡鍖栧悗鐨勬椂闂�
+ */
+ public static String formatDateTime(TemporalAccessor temporal) {
+ return DateTimeUtil.formatDateTime(temporal);
+ }
+
+ /**
+ * 鏃ユ湡鏃堕棿鏍煎紡鍖�
+ *
+ * @param temporal 鏃堕棿
+ * @return 鏍煎紡鍖栧悗鐨勬椂闂�
+ */
+ public static String formatDate(TemporalAccessor temporal) {
+ return DateTimeUtil.formatDate(temporal);
+ }
+
+ /**
+ * 鏃堕棿鏍煎紡鍖�
+ *
+ * @param temporal 鏃堕棿
+ * @return 鏍煎紡鍖栧悗鐨勬椂闂�
+ */
+ public static String formatTime(TemporalAccessor temporal) {
+ return DateTimeUtil.formatTime(temporal);
+ }
+
+ /**
+ * 灏嗗瓧绗︿覆杞崲涓烘椂闂�
+ *
+ * @param dateStr 鏃堕棿瀛楃涓�
+ * @param formatter DateTimeFormatter
+ * @return 鏃堕棿
+ */
+ public static LocalDateTime parseDateTime(String dateStr, DateTimeFormatter formatter) {
+ return DateTimeUtil.parseDateTime(dateStr, formatter);
+ }
+
+ /**
+ * 灏嗗瓧绗︿覆杞崲涓烘椂闂�
+ *
+ * @param dateStr 鏃堕棿瀛楃涓�
+ * @return 鏃堕棿
+ */
+ public static LocalDateTime parseDateTime(String dateStr) {
+ return DateTimeUtil.parseDateTime(dateStr);
+ }
+
+ /**
+ * 灏嗗瓧绗︿覆杞崲涓烘椂闂�
+ *
+ * @param dateStr 鏃堕棿瀛楃涓�
+ * @param formatter DateTimeFormatter
+ * @return 鏃堕棿
+ */
+ public static LocalDate parseDate(String dateStr, DateTimeFormatter formatter) {
+ return DateTimeUtil.parseDate(dateStr, formatter);
+ }
+
+ /**
+ * 灏嗗瓧绗︿覆杞崲涓烘棩鏈�
+ *
+ * @param dateStr 鏃堕棿瀛楃涓�
+ * @return 鏃堕棿
+ */
+ public static LocalDate parseDate(String dateStr) {
+ return DateTimeUtil.parseDate(dateStr, DateTimeUtil.DATE_FORMAT);
+ }
+
+ /**
+ * 灏嗗瓧绗︿覆杞崲涓烘椂闂�
+ *
+ * @param dateStr 鏃堕棿瀛楃涓�
+ * @param formatter DateTimeFormatter
+ * @return 鏃堕棿
+ */
+ public static LocalTime parseTime(String dateStr, DateTimeFormatter formatter) {
+ return DateTimeUtil.parseTime(dateStr, formatter);
+ }
+
+ /**
+ * 灏嗗瓧绗︿覆杞崲涓烘椂闂�
+ *
+ * @param dateStr 鏃堕棿瀛楃涓�
+ * @return 鏃堕棿
+ */
+ public static LocalTime parseTime(String dateStr) {
+ return DateTimeUtil.parseTime(dateStr);
+ }
+
+ /**
+ * 鏃堕棿姣旇緝
+ *
+ * @param startInclusive the start instant, inclusive, not null
+ * @param endExclusive the end instant, exclusive, not null
+ * @return a {@code Duration}, not null
+ */
+ public static Duration between(Temporal startInclusive, Temporal endExclusive) {
+ return Duration.between(startInclusive, endExclusive);
+ }
+
+ /**
+ * 姣旇緝2涓� 鏃堕棿宸�
+ *
+ * @param startDate 寮�濮嬫椂闂�
+ * @param endDate 缁撴潫鏃堕棿
+ * @return 鏃堕棿闂撮殧
+ */
+ public static Duration between(Date startDate, Date endDate) {
+ return DateUtil.between(startDate, endDate);
+ }
+
+ /**
+ * 瀵硅薄绫诲瀷杞崲
+ *
+ * @param source the source object
+ * @param targetType the target type
+ * @param <T> 娉涘瀷鏍囪
+ * @return the converted value
+ * @throws IllegalArgumentException if targetType is {@code null},
+ * or sourceType is {@code null} but source is not {@code null}
+ */
+ @Nullable
+ public static <T> T convert(@Nullable Object source, Class<T> targetType) {
+ return ConvertUtil.convert(source, targetType);
+ }
+
+ /**
+ * 瀵硅薄绫诲瀷杞崲
+ *
+ * @param source the source object
+ * @param sourceType the source type
+ * @param targetType the target type
+ * @param <T> 娉涘瀷鏍囪
+ * @return the converted value
+ * @throws IllegalArgumentException if targetType is {@code null},
+ * or sourceType is {@code null} but source is not {@code null}
+ */
+ @Nullable
+ public static <T> T convert(@Nullable Object source, TypeDescriptor sourceType, TypeDescriptor targetType) {
+ return ConvertUtil.convert(source, sourceType, targetType);
+ }
+
+ /**
+ * 瀵硅薄绫诲瀷杞崲
+ *
+ * @param source the source object
+ * @param targetType the target type
+ * @param <T> 娉涘瀷鏍囪
+ * @return the converted value
+ * @throws IllegalArgumentException if targetType is {@code null},
+ * or sourceType is {@code null} but source is not {@code null}
+ */
+ @Nullable
+ public static <T> T convert(@Nullable Object source, TypeDescriptor targetType) {
+ return ConvertUtil.convert(source, targetType);
+ }
+
+ /**
+ * 鑾峰彇鏂规硶鍙傛暟淇℃伅
+ *
+ * @param constructor 鏋勯�犲櫒
+ * @param parameterIndex 鍙傛暟搴忓彿
+ * @return {MethodParameter}
+ */
+ public static MethodParameter getMethodParameter(Constructor<?> constructor, int parameterIndex) {
+ return ClassUtil.getMethodParameter(constructor, parameterIndex);
+ }
+
+ /**
+ * 鑾峰彇鏂规硶鍙傛暟淇℃伅
+ *
+ * @param method 鏂规硶
+ * @param parameterIndex 鍙傛暟搴忓彿
+ * @return {MethodParameter}
+ */
+ public static MethodParameter getMethodParameter(Method method, int parameterIndex) {
+ return ClassUtil.getMethodParameter(method, parameterIndex);
+ }
+
+ /**
+ * 鑾峰彇Annotation娉ㄨВ
+ *
+ * @param annotatedElement AnnotatedElement
+ * @param annotationType 娉ㄨВ绫�
+ * @param <A> 娉涘瀷鏍囪
+ * @return {Annotation}
+ */
+ @Nullable
+ public static <A extends Annotation> A getAnnotation(AnnotatedElement annotatedElement, Class<A> annotationType) {
+ return AnnotatedElementUtils.findMergedAnnotation(annotatedElement, annotationType);
+ }
+
+ /**
+ * 鑾峰彇Annotation锛屽厛鎵炬柟娉曪紝娌℃湁鍒欏啀鎵炬柟娉曚笂鐨勭被
+ *
+ * @param method Method
+ * @param annotationType 娉ㄨВ绫�
+ * @param <A> 娉涘瀷鏍囪
+ * @return {Annotation}
+ */
+ @Nullable
+ public static <A extends Annotation> A getAnnotation(Method method, Class<A> annotationType) {
+ return ClassUtil.getAnnotation(method, annotationType);
+ }
+
+ /**
+ * 鑾峰彇Annotation锛屽厛鎵綡andlerMethod锛屾病鏈夊垯鍐嶆壘瀵瑰簲鐨勭被
+ *
+ * @param handlerMethod HandlerMethod
+ * @param annotationType 娉ㄨВ绫�
+ * @param <A> 娉涘瀷鏍囪
+ * @return {Annotation}
+ */
+ @Nullable
+ public static <A extends Annotation> A getAnnotation(HandlerMethod handlerMethod, Class<A> annotationType) {
+ return ClassUtil.getAnnotation(handlerMethod, annotationType);
+ }
+
+ /**
+ * 瀹炰緥鍖栧璞�
+ *
+ * @param clazz 绫�
+ * @param <T> 娉涘瀷鏍囪
+ * @return 瀵硅薄
+ */
+ @SuppressWarnings("unchecked")
+ public static <T> T newInstance(Class<?> clazz) {
+ return (T) BeanUtil.instantiateClass(clazz);
+ }
+
+ /**
+ * 瀹炰緥鍖栧璞�
+ *
+ * @param clazzStr 绫诲悕
+ * @param <T> 娉涘瀷鏍囪
+ * @return 瀵硅薄
+ */
+ public static <T> T newInstance(String clazzStr) {
+ return BeanUtil.newInstance(clazzStr);
+ }
+
+ /**
+ * 鑾峰彇Bean鐨勫睘鎬�
+ *
+ * @param bean bean
+ * @param propertyName 灞炴�у悕
+ * @return 灞炴�у��
+ */
+ @Nullable
+ public static Object getProperty(@Nullable Object bean, String propertyName) {
+ return BeanUtil.getProperty(bean, propertyName);
+ }
+
+ /**
+ * 璁剧疆Bean灞炴��
+ *
+ * @param bean bean
+ * @param propertyName 灞炴�у悕
+ * @param value 灞炴�у��
+ */
+ public static void setProperty(Object bean, String propertyName, Object value) {
+ BeanUtil.setProperty(bean, propertyName, value);
+ }
+
+ /**
+ * 娴呭鍒�
+ *
+ * @param source 婧愬璞�
+ * @param <T> 娉涘瀷鏍囪
+ * @return T
+ */
+ @Nullable
+ public static <T> T clone(@Nullable T source) {
+ return BeanUtil.clone(source);
+ }
+
+ /**
+ * 鎷疯礉瀵硅薄锛屾敮鎸� Map 鍜� Bean
+ *
+ * @param source 婧愬璞�
+ * @param clazz 绫诲悕
+ * @param <T> 娉涘瀷鏍囪
+ * @return T
+ */
+ @Nullable
+ public static <T> T copy(@Nullable Object source, Class<T> clazz) {
+ return BeanUtil.copy(source, clazz);
+ }
+
+ /**
+ * 鎷疯礉瀵硅薄锛屾敮鎸� Map 鍜� Bean
+ *
+ * @param source 婧愬璞�
+ * @param targetBean 闇�瑕佽祴鍊肩殑瀵硅薄
+ */
+ public static void copy(@Nullable Object source, @Nullable Object targetBean) {
+ BeanUtil.copy(source, targetBean);
+ }
+
+ /**
+ * 鎷疯礉瀵硅薄锛宻ource 瀵硅薄灞炴�у仛闈� null 鍒ゆ柇
+ *
+ * <p>
+ * 鏀寔 map bean copy
+ * </p>
+ *
+ * @param source 婧愬璞�
+ * @param targetBean 闇�瑕佽祴鍊肩殑瀵硅薄
+ */
+ public static void copyNonNull(@Nullable Object source, @Nullable Object targetBean) {
+ BeanUtil.copyNonNull(source, targetBean);
+ }
+
+ /**
+ * 鎷疯礉瀵硅薄锛屽苟瀵逛笉鍚岀被鍨嬪睘鎬ц繘琛岃浆鎹�
+ *
+ * @param source 婧愬璞�
+ * @param clazz 绫诲悕
+ * @param <T> 娉涘瀷鏍囪
+ * @return T
+ */
+ @Nullable
+ public static <T> T copyWithConvert(@Nullable Object source, Class<T> clazz) {
+ return BeanUtil.copyWithConvert(source, clazz);
+ }
+
+ /**
+ * 鎷疯礉鍒楄〃瀵硅薄
+ *
+ * <p>
+ * 鏀寔 map bean copy
+ * </p>
+ *
+ * @param sourceList 婧愬垪琛�
+ * @param targetClazz 杞崲鎴愮殑绫诲瀷
+ * @param <T> 娉涘瀷鏍囪
+ * @return T
+ */
+ public static <T> List<T> copy(@Nullable Collection<?> sourceList, Class<T> targetClazz) {
+ return BeanUtil.copy(sourceList, targetClazz);
+ }
+
+ /**
+ * 鎷疯礉鍒楄〃瀵硅薄锛屽苟瀵逛笉鍚岀被鍨嬪睘鎬ц繘琛岃浆鎹�
+ *
+ * <p>
+ * 鏀寔 map bean copy
+ * </p>
+ *
+ * @param sourceList 婧愬璞″垪琛�
+ * @param targetClazz 杞崲鎴愮殑绫�
+ * @param <T> 娉涘瀷鏍囪
+ * @return List
+ */
+ public static <T> List<T> copyWithConvert(@Nullable Collection<?> sourceList, Class<T> targetClazz) {
+ return BeanUtil.copyWithConvert(sourceList, targetClazz);
+ }
+
+ /**
+ * 鎷疯礉瀵硅薄锛屾墿灞� Spring 鐨勬嫹璐濇柟娉�
+ *
+ * @param source the source bean
+ * @param clazz the target bean class
+ * @param <T> 娉涘瀷鏍囪
+ * @return T
+ * @throws BeansException if the copying failed
+ */
+ @Nullable
+ public static <T> T copyProperties(@Nullable Object source, Class<T> clazz) throws BeansException {
+ return BeanUtil.copyProperties(source, clazz);
+ }
+
+ /**
+ * 鎷疯礉鍒楄〃瀵硅薄锛屾墿灞� Spring 鐨勬嫹璐濇柟娉�
+ *
+ * @param sourceList the source list bean
+ * @param targetClazz the target bean class
+ * @param <T> 娉涘瀷鏍囪
+ * @return List
+ * @throws BeansException if the copying failed
+ */
+ public static <T> List<T> copyProperties(@Nullable Collection<?> sourceList, Class<T> targetClazz) throws BeansException {
+ return BeanUtil.copyProperties(sourceList, targetClazz);
+ }
+
+ /**
+ * 灏嗗璞¤鎴恗ap褰㈠紡
+ *
+ * @param bean 婧愬璞�
+ * @return {Map}
+ */
+ public static Map<String, Object> toMap(@Nullable Object bean) {
+ return BeanUtil.toMap(bean);
+ }
+
+ /**
+ * 灏唌ap 杞负 bean
+ *
+ * @param beanMap map
+ * @param valueType 瀵硅薄绫诲瀷
+ * @param <T> 娉涘瀷鏍囪
+ * @return {T}
+ */
+ public static <T> T toBean(Map<String, Object> beanMap, Class<T> valueType) {
+ return BeanUtil.toBean(beanMap, valueType);
+ }
+
+}
--
Gitblit v1.9.3