工具包集合,工具类快捷方式

类名: $

requireNotNull

/**
* 断言,必须不能为 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}
*/
$.requireNotNull(T obj);

requireNotNull

/**
* 断言,必须不能为 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}
*/
$.requireNotNull(T obj, String message);

requireNotNull

/**
* 断言,必须不能为 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}
*/
$.requireNotNull(T obj, Supplier<String> messageSupplier);

isTrue

/**
* 判断对象为true
*
* @param object 对象
* @return 对象是否为true
*/
$.isTrue(Boolean object);

isFalse

/**
* 判断对象为false
*
* @param object 对象
* @return 对象是否为false
*/
$.isFalse(Boolean object);

isNull

/**
* 判断对象是否为null
* <p>
* This method exists to be used as a
* {@link java.util.function.Predicate}, {@code context($::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
*/
$.isNull(Object obj);

isNotNull

/**
* 判断对象是否 not null
* <p>
* This method exists to be used as a
* {@link java.util.function.Predicate}, {@code context($::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
*/
$.isNotNull(Object obj);

firstCharToLower

/**
* 首字母变小写
*
* @param str 字符串
* @return {String}
*/
$.firstCharToLower(String str);

firstCharToUpper

/**
* 首字母变大写
*
* @param str 字符串
* @return {String}
*/
$.firstCharToUpper(String str);

isBlank

/**
* 判断是否为空字符串
* <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
*/
$.isBlank(CharSequence cs);

isNotBlank

/**
* 判断不为空字符串
* <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
*/
$.isNotBlank(CharSequence cs);

isAnyBlank

/**
* 判断是否有任意一个 空字符串
*
* @param css CharSequence
* @return boolean
*/
$.isAnyBlank(CharSequence css);

isAnyBlank

/**
* 有 任意 一个 Blank
*
* @param css CharSequence
* @return boolean
*/
$.isAnyBlank(Collection<CharSequence> css);

isNoneBlank

/**
* 判断是否全为非空字符串
*
* @param css CharSequence
* @return boolean
*/
$.isNoneBlank(CharSequence css);

isNoneBlank

/**
* 是否全非 Blank
*
* @param css CharSequence
* @return boolean
*/
$.isNoneBlank(Collection<CharSequence> css);

isAnyNotBlank

/**
* 有 任意 一个 Blank
*
* @param css CharSequence
* @return boolean
*/
$.isAnyNotBlank(CharSequence css);

isAnyNotBlank

/**
* 有 任意 一个 Blank
*
* @param css CharSequence
* @return boolean
*/
$.isAnyNotBlank(Collection<CharSequence> css);

isArray

/**
* 判断对象是数组
*
* @param obj the object to check
* @return 是否数组
*/
$.isArray(Object obj);

isEmpty

/**
* 判断空对象 object、map、list、set、字符串、数组
*
* @param obj the object to check
* @return 数组是否为空
*/
$.isEmpty(Object obj);

isNotEmpty

/**
* 对象不为空 object、map、list、set、字符串、数组
*
* @param obj the object to check
* @return 是否不为空
*/
$.isNotEmpty(Object obj);

isEmpty

/**
* 判断数组为空
*
* @param array the array to check
* @return 数组是否为空
*/
$.isEmpty(Object[] array);

isNotEmpty

/**
* 判断数组不为空
*
* @param array 数组
* @return 数组是否不为空
*/
$.isNotEmpty(Object[] array);

format

/**
* 将字符串中特定模式的字符转换成map中对应的值
* <p>
* use: format("my name is ${name}, and i like ${like}!", {"name":"L.cm", "like": "Java"})
*
* @param message 需要转换的字符串
* @param params 转换所需的键值对集合
* @return 转换后的字符串
*/
$.format(String message, Map<String,Object> params);

format

/**
* 同 log 格式的 format 规则
* <p>
* use: format("my name is {}, and i like {}!", "L.cm", "Java")
*
* @param message 需要转换的字符串
* @param arguments 需要替换的变量
* @return 转换后的字符串
*/
$.format(String message, Object arguments);

cleanText

/**
* 清理字符串,清理出某些不可见字符和一些sql特殊字符
*
* @param txt 文本
* @return {String}
*/
$.cleanText(String txt);

cleanIdentifier

/**
* 获取标识符,用于参数清理
*
* @param param 参数
* @return 清理后的标识符
*/
$.cleanIdentifier(String param);

equalsSafe

/**
* 安全的 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
*/
$.equalsSafe(Object o1, Object o2);

equals

/**
* 对象 eq
*
* @param o1 Object
* @param o2 Object
* @return 是否eq
*/
$.equals(Object o1, Object o2);

isNotEqual

/**
* 比较两个对象是否不相等。<br>
*
* @param o1 对象1
* @param o2 对象2
* @return 是否不eq
*/
$.isNotEqual(Object o1, Object o2);

hashCode

/**
* 返回对象的 hashCode
*
* @param obj Object
* @return hashCode
*/
$.hashCode(Object obj);

defaultIfNull

/**
* 如果对象为null,返回默认值
*
* @param object Object
* @param defaultValue 默认值
* @return Object
*/
$.defaultIfNull(Object object, Object defaultValue);

contains

/**
* 判断数组中是否包含元素
*
* @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
*/
$.contains(T[] array, T element);

contains

/**
* 判断迭代器中是否包含元素
*
* @param iterator the Iterator to check
* @param element the element to look for
* @return {@code true} if found, {@code false} otherwise
*/
$.contains(Iterator<?> iterator, Object element);

contains

/**
* 判断枚举是否包含该元素
*
* @param enumeration the Enumeration to check
* @param element the element to look for
* @return {@code true} if found, {@code false} otherwise
*/
$.contains(Enumeration<?> enumeration, Object element);

concat

/**
* Concatenates 2 arrays
*
* @param one 数组1
* @param other 数组2
* @return 新数组
*/
$.concat(String[] one, String[] other);

concat

/**
* Concatenates 2 arrays
*
* @param one 数组1
* @param other 数组2
* @param clazz 数组类
* @return 新数组
*/
$.concat(T[] one, T[] other, Class<T> clazz);

ofImmutableSet

/**
* 不可变 Set
*
* @param es 对象
* @param <E> 泛型
* @return 集合
*/
$.ofImmutableSet(E es);

ofImmutableList

/**
* 不可变 List
*
* @param es 对象
* @param <E> 泛型
* @return 集合
*/
$.ofImmutableList(E es);

toList

/**
* Iterable 转换为List集合
*
* @param elements Iterable
* @param <E> 泛型
* @return 集合
*/
$.toList(Iterable<E> elements);

toMap

/**
* 将key value 数组转为 map
*
* @param keysValues key value 数组
* @param <K> key
* @param <V> value
* @return map 集合
*/
$.toMap(Object keysValues);

partition

/**
* list 分片
*
* @param list List
* @param size 分片大小
* @param <T> 泛型
* @return List 分片
*/
$.partition(List<T> list, int size);

isNumeric

/**
* 判断一个字符串是否是数字
*
* @param cs the CharSequence to check, may be null
* @return {boolean}
*/
$.isNumeric(CharSequence cs);

toStr

/**
* 强转string
*
* @param object Object
* @return String
*/
$.toStr(Object object);

toStr

/**
* 强转string
*
* @param object Object
* @param defaultValue 默认值
* @return String
*/
$.toStr(Object object, String defaultValue);

toInt

/**
* 对象转为 int (支持 String 和 Number),默认: 0
*
* @param object Object
* @return int
*/
$.toInt(Object object);

toInt

/**
* 对象转为 int (支持 String 和 Number)
*
* @param object Object
* @param defaultValue 默认值
* @return int
*/
$.toInt(Object object, int defaultValue);

toLong

/**
* 对象转为 long (支持 String 和 Number),默认: 0L
*
* @param object Object
* @return long
*/
$.toLong(Object object);

toLong

/**
* 对象转为 long (支持 String 和 Number),默认: 0L
*
* @param object Object
* @return long
*/
$.toLong(Object object, long defaultValue);

toFloat

/**
* 对象转为 Float
*
* @param object Object
* @return 结果
*/
$.toFloat(Object object);

toFloat

/**
* 对象转为 Float
*
* @param object Object
* @param defaultValue float
* @return 结果
*/
$.toFloat(Object object, float defaultValue);

toDouble

/**
* 对象转为 Double
*
* @param object Object
* @return 结果
*/
$.toDouble(Object object);

toDouble

/**
* 对象转为 Double
*
* @param object Object
* @param defaultValue double
* @return 结果
*/
$.toDouble(Object object, double defaultValue);

toByte

/**
* 对象转为 Byte
*
* @param object Object
* @return 结果
*/
$.toByte(Object object);

toByte

/**
* 对象转为 Byte
*
* @param object Object
* @param defaultValue byte
* @return 结果
*/
$.toByte(Object object, byte defaultValue);

toShort

/**
* 对象转为 Short
*
* @param object Object
* @return 结果
*/
$.toShort(Object object);

toShort

/**
* 对象转为 Short
*
* @param object Object
* @param defaultValue short
* @return 结果
*/
$.toShort(Object object, short defaultValue);

toBoolean

/**
* 对象转为 Boolean
*
* @param object Object
* @return 结果
*/
$.toBoolean(Object object);

toBoolean

/**
* 对象转为 Boolean
*
* @param object Object
* @param defaultValue 默认值
* @return 结果
*/
$.toBoolean(Object object, Boolean defaultValue);

to62Str

/**
* 将 long 转短字符串 为 62 进制
*
* @param num 数字
* @return 短字符串
*/
$.to62Str(long num);

join

/**
* 将集合拼接成字符串,默认使用`,`拼接
*
* @param coll the {@code Collection} to convert
* @return the delimited {@code String}
*/
$.join(Collection<?> coll);

join

/**
* 将集合拼接成字符串,默认指定分隔符
*
* @param coll the {@code Collection} to convert
* @param delim the delimiter to use (typically a ",")
* @return the delimited {@code String}
*/
$.join(Collection<?> coll, String delim);

join

/**
* 将数组拼接成字符串,默认使用`,`拼接
*
* @param arr the array to display
* @return the delimited {@code String}
*/
$.join(Object[] arr);

join

/**
* 将数组拼接成字符串,默认指定分隔符
*
* @param arr the array to display
* @param delim the delimiter to use (typically a ",")
* @return the delimited {@code String}
*/
$.join(Object[] arr, String delim);

split

/**
* 分割 字符串
*
* @param str 字符串
* @param delimiter 分割符
* @return 字符串数组
*/
$.split(String str, String delimiter);

splitTrim

/**
* 分割 字符串 删除常见 空白符
*
* @param str 字符串
* @param delimiter 分割符
* @return 字符串数组
*/
$.splitTrim(String str, String delimiter);

simpleMatch

/**
* 字符串是否符合指定的 表达式
*
* <p>
* pattern styles: "xxx*", "*xxx", "*xxx*" and "xxx*yyy"
* </p>
*
* @param pattern 表达式
* @param str 字符串
* @return 是否匹配
*/
$.simpleMatch(String pattern, String str);

simpleMatch

/**
* 字符串是否符合指定的 表达式
*
* <p>
* pattern styles: "xxx*", "*xxx", "*xxx*" and "xxx*yyy"
* </p>
*
* @param patterns 表达式 数组
* @param str 字符串
* @return 是否匹配
*/
$.simpleMatch(String[] patterns, String str);

getUUID

/**
* 生成uuid
*
* @return UUID
*/
$.getUUID();

escapeHtml

/**
* 转义HTML用于安全过滤
*
* @param html html
* @return {String}
*/
$.escapeHtml(String html);

random

/**
* 随机数生成
*
* @param count 字符长度
* @return 随机数
*/
$.random(int count);

random

/**
* 随机数生成
*
* @param count 字符长度
* @param randomType 随机数类别
* @return 随机数
*/
$.random(int count, RandomType randomType);

md5

/**
* Calculates the MD5 digest.
*
* @param data Data to digest
* @return MD5 digest as a hex array
*/
$.md5(byte[] data);

md5

/**
* Calculates the MD5 digest.
*
* @param data Data to digest
* @return MD5 digest as a hex array
*/
$.md5(String data);

md5Hex

/**
* Calculates the MD5 digest and returns the value as a 32 character hex string.
*
* @param data Data to digest
* @return MD5 digest as a hex string
*/
$.md5Hex(String data);

md5Hex

/**
* Return a hexadecimal string representation of the MD5 digest of the given bytes.
*
* @param bytes the bytes to calculate the digest over
* @return a hexadecimal digest string
*/
$.md5Hex(byte[] bytes);

sha1

/**
* sha1
*
* @param data Data to digest
* @return digest as a hex array
*/
$.sha1(String data);

sha1

/**
* sha1
*
* @param bytes Data to digest
* @return digest as a hex array
*/
$.sha1(byte[] bytes);

sha1Hex

/**
* sha1Hex
*
* @param data Data to digest
* @return digest as a hex string
*/
$.sha1Hex(String data);

sha1Hex

/**
* sha1Hex
*
* @param bytes Data to digest
* @return digest as a hex string
*/
$.sha1Hex(byte[] bytes);

sha224

/**
* SHA224
*
* @param data Data to digest
* @return digest as a byte array
*/
$.sha224(String data);

sha224

/**
* SHA224
*
* @param bytes Data to digest
* @return digest as a byte array
*/
$.sha224(byte[] bytes);

sha224Hex

/**
* SHA224Hex
*
* @param data Data to digest
* @return digest as a hex string
*/
$.sha224Hex(String data);

sha224Hex

/**
* SHA224Hex
*
* @param bytes Data to digest
* @return digest as a hex string
*/
$.sha224Hex(byte[] bytes);

sha256

/**
* sha256Hex
*
* @param data Data to digest
* @return digest as a byte array
*/
$.sha256(String data);

sha256

/**
* sha256Hex
*
* @param bytes Data to digest
* @return digest as a byte array
*/
$.sha256(byte[] bytes);

sha256Hex

/**
* sha256Hex
*
* @param data Data to digest
* @return digest as a hex string
*/
$.sha256Hex(String data);

sha256Hex

/**
* sha256Hex
*
* @param bytes Data to digest
* @return digest as a hex string
*/
$.sha256Hex(byte[] bytes);

sha384

/**
* sha384
*
* @param data Data to digest
* @return digest as a byte array
*/
$.sha384(String data);

sha384

/**
* sha384
*
* @param bytes Data to digest
* @return digest as a byte array
*/
$.sha384(byte[] bytes);

sha384Hex

/**
* sha384Hex
*
* @param data Data to digest
* @return digest as a hex string
*/
$.sha384Hex(String data);

sha384Hex

/**
* sha384Hex
*
* @param bytes Data to digest
* @return digest as a hex string
*/
$.sha384Hex(byte[] bytes);

sha512

/**
* sha512Hex
*
* @param data Data to digest
* @return digest as a byte array
*/
$.sha512(String data);

sha512

/**
* sha512Hex
*
* @param bytes Data to digest
* @return digest as a byte array
*/
$.sha512(byte[] bytes);

sha512Hex

/**
* sha512Hex
*
* @param data Data to digest
* @return digest as a hex string
*/
$.sha512Hex(String data);

sha512Hex

/**
* sha512Hex
*
* @param bytes Data to digest
* @return digest as a hex string
*/
$.sha512Hex(byte[] bytes);

hmacMd5

/**
* hmacMd5
*
* @param data Data to digest
* @param key key
* @return digest as a byte array
*/
$.hmacMd5(String data, String key);

hmacMd5

/**
* hmacMd5
*
* @param bytes Data to digest
* @param key key
* @return digest as a byte array
*/
$.hmacMd5(byte[] bytes, String key);

hmacMd5Hex

/**
* hmacMd5 Hex
*
* @param data Data to digest
* @param key key
* @return digest as a hex string
*/
$.hmacMd5Hex(String data, String key);

hmacMd5Hex

/**
* hmacMd5 Hex
*
* @param bytes Data to digest
* @param key key
* @return digest as a hex string
*/
$.hmacMd5Hex(byte[] bytes, String key);

hmacSha1

/**
* hmacSha1
*
* @param data Data to digest
* @param key key
* @return digest as a byte array
*/
$.hmacSha1(String data, String key);

hmacSha1

/**
* hmacSha1
*
* @param bytes Data to digest
* @param key key
* @return digest as a byte array
*/
$.hmacSha1(byte[] bytes, String key);

hmacSha1Hex

/**
* hmacSha1 Hex
*
* @param data Data to digest
* @param key key
* @return digest as a hex string
*/
$.hmacSha1Hex(String data, String key);

hmacSha1Hex

/**
* hmacSha1 Hex
*
* @param bytes Data to digest
* @param key key
* @return digest as a hex string
*/
$.hmacSha1Hex(byte[] bytes, String key);

hmacSha224

/**
* hmacSha224
*
* @param data Data to digest
* @param key key
* @return digest as a hex string
*/
$.hmacSha224(String data, String key);

hmacSha224

/**
* hmacSha224
*
* @param bytes Data to digest
* @param key key
* @return digest as a hex string
*/
$.hmacSha224(byte[] bytes, String key);

hmacSha224Hex

/**
* hmacSha224 Hex
*
* @param data Data to digest
* @param key key
* @return digest as a hex string
*/
$.hmacSha224Hex(String data, String key);

hmacSha224Hex

/**
* hmacSha224 Hex
*
* @param bytes Data to digest
* @param key key
* @return digest as a hex string
*/
$.hmacSha224Hex(byte[] bytes, String key);

hmacSha256

/**
* hmacSha256
*
* @param data Data to digest
* @param key key
* @return digest as a hex string
*/
$.hmacSha256(String data, String key);

hmacSha256

/**
* hmacSha256
*
* @param bytes Data to digest
* @param key key
* @return digest as a byte array
*/
$.hmacSha256(byte[] bytes, String key);

hmacSha256Hex

/**
* hmacSha256 Hex
*
* @param data Data to digest
* @param key key
* @return digest as a byte array
*/
$.hmacSha256Hex(String data, String key);

hmacSha256Hex

/**
* hmacSha256 Hex
*
* @param bytes Data to digest
* @param key key
* @return digest as a hex string
*/
$.hmacSha256Hex(byte[] bytes, String key);

hmacSha384

/**
* hmacSha384
*
* @param data Data to digest
* @param key key
* @return digest as a byte array
*/
$.hmacSha384(String data, String key);

hmacSha384

/**
* hmacSha384
*
* @param bytes Data to digest
* @param key key
* @return digest as a byte array
*/
$.hmacSha384(byte[] bytes, String key);

hmacSha384Hex

/**
* hmacSha384 Hex
*
* @param data Data to digest
* @param key key
* @return digest as a hex string
*/
$.hmacSha384Hex(String data, String key);

hmacSha384Hex

/**
* hmacSha384 Hex
*
* @param bytes Data to digest
* @param key key
* @return digest as a hex string
*/
$.hmacSha384Hex(byte[] bytes, String key);

hmacSha512

/**
* hmacSha512
*
* @param data Data to digest
* @param key key
* @return digest as a byte array
*/
$.hmacSha512(String data, String key);

hmacSha512

/**
* hmacSha512
*
* @param bytes Data to digest
* @param key key
* @return digest as a byte array
*/
$.hmacSha512(byte[] bytes, String key);

hmacSha512Hex

/**
* hmacSha512 Hex
*
* @param data Data to digest
* @param key key
* @return digest as a hex string
*/
$.hmacSha512Hex(String data, String key);

hmacSha512Hex

/**
* hmacSha512 Hex
*
* @param bytes Data to digest
* @param key key
* @return digest as a hex string
*/
$.hmacSha512Hex(byte[] bytes, String key);

encodeHex

/**
* byte 数组序列化成 hex
*
* @param bytes bytes to encode
* @return MD5 digest as a hex string
*/
$.encodeHex(byte[] bytes);

decodeHex

/**
* 字符串反序列化成 hex
*
* @param hexString String to decode
* @return MD5 digest as a hex string
*/
$.decodeHex(String hexString);

encodeBase64

/**
* Base64编码
*
* @param value 字符串
* @return {String}
*/
$.encodeBase64(String value);

encodeBase64

/**
* Base64编码
*
* @param value 字符串
* @param charset 字符集
* @return {String}
*/
$.encodeBase64(String value, Charset charset);

encodeBase64UrlSafe

/**
* Base64编码为URL安全
*
* @param value 字符串
* @return {String}
*/
$.encodeBase64UrlSafe(String value);

encodeBase64UrlSafe

/**
* Base64编码为URL安全
*
* @param value 字符串
* @param charset 字符集
* @return {String}
*/
$.encodeBase64UrlSafe(String value, Charset charset);

decodeBase64

/**
* Base64解码
*
* @param value 字符串
* @return {String}
*/
$.decodeBase64(String value);

decodeBase64

/**
* Base64解码
*
* @param value 字符串
* @param charset 字符集
* @return {String}
*/
$.decodeBase64(String value, Charset charset);

decodeBase64UrlSafe

/**
* Base64URL安全解码
*
* @param value 字符串
* @return {String}
*/
$.decodeBase64UrlSafe(String value);

decodeBase64UrlSafe

/**
* Base64URL安全解码
*
* @param value 字符串
* @param charset 字符集
* @return {String}
*/
$.decodeBase64UrlSafe(String value, Charset charset);

closeQuietly

/**
* 关闭 Closeable
*
* @param closeable 自动关闭
*/
$.closeQuietly(Closeable closeable);

readToString

/**
* 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
*/
$.readToString(InputStream input);

readToString

/**
* 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
*/
$.readToString(InputStream input, Charset charset);

readToByteArray

/**
* InputStream to bytes 数组
*
* @param input InputStream
* @return the requested byte array
*/
$.readToByteArray(InputStream input);

readToString

/**
* 读取文件为字符串
*
* @param file the file to read, must not be {@code null}
* @return the file contents, never {@code null}
*/
$.readToString(File file);

readToString

/**
* 读取文件为字符串
*
* @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}
*/
$.readToString(File file, Charset encoding);

readToByteArray

/**
* 读取文件为 byte 数组
*
* @param file the file to read, must not be {@code null}
* @return the file contents, never {@code null}
*/
$.readToByteArray(File file);

toTempDirPath

/**
* 拼接临时文件目录.
*
* @return 临时文件目录.
*/
$.toTempDirPath(String subDirFile);

getTempDir

/**
* Returns a {@link File} representing the system temporary directory.
*
* @return the system temporary directory.
*/
$.getTempDir();

toTempDir

/**
* 拼接临时文件目录.
*
* @return 临时文件目录.
*/
$.toTempDir(String subDirFile);

getResource

/**
* 获取资源,注意:boot 中请不要使用 Resource getFile,应该使用 getInputStream,支持一下协议:
*
* <p>
* 1. classpath:
* 2. file:
* 3. ftp:
* 4. http: and https:
* 6. C:/dir1/ and /Users/lcm
* </p>
*
* @param resourceLocation 资源路径
* @return Resource
* @throws IOException io异常
*/
$.getResource(String resourceLocation);

toJson

/**
* 将对象序列化成json字符串
*
* @param object javaBean
* @return jsonString json字符串
*/
$.toJson(Object object);

toJsonAsBytes

/**
* 将对象序列化成 json byte 数组
*
* @param object javaBean
* @return jsonString json字符串
*/
$.toJsonAsBytes(Object object);

readTree

/**
* 将json字符串转成 JsonNode
*
* @param jsonString jsonString
* @return jsonString json字符串
*/
$.readTree(String jsonString);

readTree

/**
* 将json字符串转成 JsonNode
*
* @param in InputStream
* @return jsonString json字符串
*/
$.readTree(InputStream in);

readTree

/**
* 将json字符串转成 JsonNode
*
* @param content content
* @return jsonString json字符串
*/
$.readTree(byte[] content);

readTree

/**
* 将json字符串转成 JsonNode
*
* @param jsonParser JsonParser
* @return jsonString json字符串
*/
$.readTree(JsonParser jsonParser);

readJson

/**
* 将json byte 数组反序列化成对象
*
* @param bytes json bytes
* @param valueType class
* @param <T> T 泛型标记
* @return Bean
*/
$.readJson(byte[] bytes, Class<T> valueType);

readJson

/**
* 将json反序列化成对象
*
* @param jsonString jsonString
* @param valueType class
* @param <T> T 泛型标记
* @return Bean
*/
$.readJson(String jsonString, Class<T> valueType);

readJson

/**
* 将json反序列化成对象
*
* @param in InputStream
* @param valueType class
* @param <T> T 泛型标记
* @return Bean
*/
$.readJson(InputStream in, Class<T> valueType);

readJson

/**
* 将json反序列化成对象
*
* @param bytes bytes
* @param typeReference 泛型类型
* @param <T> T 泛型标记
* @return Bean
*/
$.readJson(byte[] bytes, TypeReference<T> typeReference);

readJson

/**
* 将json反序列化成对象
*
* @param jsonString jsonString
* @param typeReference 泛型类型
* @param <T> T 泛型标记
* @return Bean
*/
$.readJson(String jsonString, TypeReference<T> typeReference);

readJsonAsJson

/**
* 将json反序列化成对象
*
* @param in InputStream
* @param typeReference 泛型类型
* @param <T> T 泛型标记
* @return Bean
*/
$.readJsonAsJson(InputStream in, TypeReference<T> typeReference);

readJsonAsList

/**
* 读取集合
*
* @param content bytes
* @param elementClass elementClass
* @param <T> 泛型
* @return 集合
*/
$.readJsonAsList(byte[] content, Class<T> elementClass);

readJsonAsList

/**
* 读取集合
*
* @param content InputStream
* @param elementClass elementClass
* @param <T> 泛型
* @return 集合
*/
$.readJsonAsList(InputStream content, Class<T> elementClass);

readJsonAsList

/**
* 读取集合
*
* @param content bytes
* @param elementClass elementClass
* @param <T> 泛型
* @return 集合
*/
$.readJsonAsList(String content, Class<T> elementClass);

readJsonAsMap

/**
* 读取集合
*
* @param content bytes
* @param keyClass key类型
* @param valueClass 值类型
* @param <K> 泛型
* @param <V> 泛型
* @return 集合
*/
$.readJsonAsMap(byte[] content, Class<?> keyClass, Class<?> valueClass);

readJsonAsMap

/**
* 读取集合
*
* @param content InputStream
* @param keyClass key类型
* @param valueClass 值类型
* @param <K> 泛型
* @param <V> 泛型
* @return 集合
*/
$.readJsonAsMap(InputStream content, Class<?> keyClass, Class<?> valueClass);

readJsonAsMap

/**
* 读取集合
*
* @param content bytes
* @param keyClass key类型
* @param valueClass 值类型
* @param <K> 泛型
* @param <V> 泛型
* @return 集合
*/
$.readJsonAsMap(String content, Class<?> keyClass, Class<?> valueClass);

urlEncode

/**
* url 编码
*
* @param source the String to be encoded
* @return the encoded String
*/
$.urlEncode(String source);

urlEncode

/**
* url 编码
*
* @param source the String to be encoded
* @param charset the character encoding to encode to
* @return the encoded String
*/
$.urlEncode(String source, Charset charset);

urlDecode

/**
* url 解码
*
* @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)
*/
$.urlDecode(String source);

urlDecode

/**
* url 解码
*
* @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)
*/
$.urlDecode(String source, Charset charset);

formatDateTime

/**
* 日期时间格式化
*
* @param date 时间
* @return 格式化后的时间
*/
$.formatDateTime(Date date);

formatDate

/**
* 日期格式化
*
* @param date 时间
* @return 格式化后的时间
*/
$.formatDate(Date date);

formatTime

/**
* 时间格式化
*
* @param date 时间
* @return 格式化后的时间
*/
$.formatTime(Date date);

format

/**
* 对象格式化 支持数字,date,java8时间
*
* @param object 格式化对象
* @param pattern 表达式
* @return 格式化后的字符串
*/
$.format(Object object, String pattern);

parseDate

/**
* 将字符串转换为时间
*
* @param dateStr 时间字符串
* @param pattern 表达式
* @return 时间
*/
$.parseDate(String dateStr, String pattern);

parse

/**
* 将字符串转换为时间
*
* @param dateStr 时间字符串
* @param formatter DateTimeFormatter
* @return 时间
*/
$.parse(String dateStr, DateTimeFormatter formatter);

formatDateTime

/**
* 日期时间格式化
*
* @param temporal 时间
* @return 格式化后的时间
*/
$.formatDateTime(TemporalAccessor temporal);

formatDate

/**
* 日期时间格式化
*
* @param temporal 时间
* @return 格式化后的时间
*/
$.formatDate(TemporalAccessor temporal);

formatTime

/**
* 时间格式化
*
* @param temporal 时间
* @return 格式化后的时间
*/
$.formatTime(TemporalAccessor temporal);

parseDateTime

/**
* 将字符串转换为时间
*
* @param dateStr 时间字符串
* @param formatter DateTimeFormatter
* @return 时间
*/
$.parseDateTime(String dateStr, DateTimeFormatter formatter);

parseDateTime

/**
* 将字符串转换为时间
*
* @param dateStr 时间字符串
* @return 时间
*/
$.parseDateTime(String dateStr);

parseDate

/**
* 将字符串转换为时间
*
* @param dateStr 时间字符串
* @param formatter DateTimeFormatter
* @return 时间
*/
$.parseDate(String dateStr, DateTimeFormatter formatter);

parseDate

/**
* 将字符串转换为日期
*
* @param dateStr 时间字符串
* @return 时间
*/
$.parseDate(String dateStr);

parseTime

/**
* 将字符串转换为时间
*
* @param dateStr 时间字符串
* @param formatter DateTimeFormatter
* @return 时间
*/
$.parseTime(String dateStr, DateTimeFormatter formatter);

parseTime

/**
* 将字符串转换为时间
*
* @param dateStr 时间字符串
* @return 时间
*/
$.parseTime(String dateStr);

between

/**
* 时间比较
*
* @param startInclusive the start instant, inclusive, not null
* @param endExclusive the end instant, exclusive, not null
* @return a {@code Duration}, not null
*/
$.between(Temporal startInclusive, Temporal endExclusive);

between

/**
* 比较2个 时间差
*
* @param startDate 开始时间
* @param endDate 结束时间
* @return 时间间隔
*/
$.between(Date startDate, Date endDate);

convert

/**
* 对象类型转换
*
* @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}
*/
$.convert(Object source, Class<T> targetType);

convert

/**
* 对象类型转换
*
* @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}
*/
$.convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType);

convert

/**
* 对象类型转换
*
* @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}
*/
$.convert(Object source, TypeDescriptor targetType);

getMethodParameter

/**
* 获取方法参数信息
*
* @param constructor 构造器
* @param parameterIndex 参数序号
* @return {MethodParameter}
*/
$.getMethodParameter(Constructor<?> constructor, int parameterIndex);

getMethodParameter

/**
* 获取方法参数信息
*
* @param method 方法
* @param parameterIndex 参数序号
* @return {MethodParameter}
*/
$.getMethodParameter(Method method, int parameterIndex);

getAnnotation

/**
* 获取Annotation注解
*
* @param annotatedElement AnnotatedElement
* @param annotationType 注解类
* @param <A> 泛型标记
* @return {Annotation}
*/
$.getAnnotation(AnnotatedElement annotatedElement, Class<A> annotationType);

getAnnotation

/**
* 获取Annotation,先找方法,没有则再找方法上的类
*
* @param method Method
* @param annotationType 注解类
* @param <A> 泛型标记
* @return {Annotation}
*/
$.getAnnotation(Method method, Class<A> annotationType);

getAnnotation

/**
* 获取Annotation,先找HandlerMethod,没有则再找对应的类
*
* @param handlerMethod HandlerMethod
* @param annotationType 注解类
* @param <A> 泛型标记
* @return {Annotation}
*/
$.getAnnotation(HandlerMethod handlerMethod, Class<A> annotationType);

newInstance

/**
* 实例化对象
*
* @param clazz 类
* @param <T> 泛型标记
* @return 对象
*/
$.newInstance(Class<?> clazz);

newInstance

/**
* 实例化对象
*
* @param clazzStr 类名
* @param <T> 泛型标记
* @return 对象
*/
$.newInstance(String clazzStr);

getProperty

/**
* 获取Bean的属性
*
* @param bean bean
* @param propertyName 属性名
* @return 属性值
*/
$.getProperty(Object bean, String propertyName);

setProperty

/**
* 设置Bean属性
*
* @param bean bean
* @param propertyName 属性名
* @param value 属性值
*/
$.setProperty(Object bean, String propertyName, Object value);

clone

/**
* 浅复制
*
* @param source 源对象
* @param <T> 泛型标记
* @return T
*/
$.clone(T source);

copy

/**
* 拷贝对象,支持 Map 和 Bean
*
* @param source 源对象
* @param clazz 类名
* @param <T> 泛型标记
* @return T
*/
$.copy(Object source, Class<T> clazz);

copy

/**
* 拷贝对象,支持 Map 和 Bean
*
* @param source 源对象
* @param targetBean 需要赋值的对象
*/
$.copy(Object source, Object targetBean);

copyNonNull

/**
* 拷贝对象,source 对象属性做非 null 判断
*
* <p>
* 支持 map bean copy
* </p>
*
* @param source 源对象
* @param targetBean 需要赋值的对象
*/
$.copyNonNull(Object source, Object targetBean);

copyWithConvert

/**
* 拷贝对象,并对不同类型属性进行转换
*
* @param source 源对象
* @param clazz 类名
* @param <T> 泛型标记
* @return T
*/
$.copyWithConvert(Object source, Class<T> clazz);

copy

/**
* 拷贝列表对象
*
* <p>
* 支持 map bean copy
* </p>
*
* @param sourceList 源列表
* @param targetClazz 转换成的类型
* @param <T> 泛型标记
* @return T
*/
$.copy(Collection<?> sourceList, Class<T> targetClazz);

copyWithConvert

/**
* 拷贝列表对象,并对不同类型属性进行转换
*
* <p>
* 支持 map bean copy
* </p>
*
* @param sourceList 源对象列表
* @param targetClazz 转换成的类
* @param <T> 泛型标记
* @return List
*/
$.copyWithConvert(Collection<?> sourceList, Class<T> targetClazz);

copyProperties

/**
* 拷贝对象,扩展 Spring 的拷贝方法
*
* @param source the source bean
* @param clazz the target bean class
* @param <T> 泛型标记
* @return T
* @throws BeansException if the copying failed
*/
$.copyProperties(Object source, Class<T> clazz);

copyProperties

/**
* 拷贝列表对象,扩展 Spring 的拷贝方法
*
* @param sourceList the source list bean
* @param targetClazz the target bean class
* @param <T> 泛型标记
* @return List
* @throws BeansException if the copying failed
*/
$.copyProperties(Collection<?> sourceList, Class<T> targetClazz);

toMap

/**
* 将对象装成map形式
*
* @param bean 源对象
* @return {Map}
*/
$.toMap(Object bean);

toBean

/**
* 将map 转为 bean
*
* @param beanMap map
* @param valueType 对象类型
* @param <T> 泛型标记
* @return {T}
*/
$.toBean(Map<String,Object> beanMap, Class<T> valueType);

微信 vs 公众号

如梦技术

精彩内容每日推荐!!!