我是靠谱客的博主 无辜苗条,这篇文章主要介绍深入浅出org.springframework.utilbackoffcomparatorconcurrentfunctionunitxml其他,现在分享给大家,希望可以做个参考。
别再自己瞎写工具类了,Spring Boot 内置工具类应有尽有
本节我们来研究一下Spring官方提供的工具类
backoff
comparator
concurrent
function
unit
xml
其他
Assert (断言工具类)
基本用法:我断言(认定),如果不成立,返回msg中的提示信息。
notNull、isNull
复制代码
1
2
3
4
5
6String str = null; Assert.notNull(str, "str为空"); String str1 = "abc"; Assert.isNull(str1, "str不为空");
断言不为空,为空抛异常;断言为空,不为空抛异常。
isTrue
复制代码
1
2
3boolean f = false; Assert.isTrue(f, "f为false");
notEmpty 是否为空
复制代码
1
2
3ArrayList list = null; Assert.notEmpty(list, "list为空");
noNullElements 是否有元素
复制代码
1
2
3Object[] ar = new Object[1]; Assert.noNullElements(ar,"数组为空");
基本用法:可以用来替代 if 进行参数校验。
AlternativeJdkIdGenerator(uuid生成工具)
复制代码
1
2
3
4
5
6
7
8
9public class AlternativeJdkIdGeneratorDemo { public static void main(String[] args) { AlternativeJdkIdGenerator alternativeJdkIdGenerator = new AlternativeJdkIdGenerator(); UUID uuid = alternativeJdkIdGenerator.generateId(); System.out.println(uuid); System.out.println(UUID.randomUUID().toString()); } }
复制代码
1
2
35c3da762-4b29-7bd7-a625-2840b4cde935 b56ebdfa-2369-4354-9fff-b121579c2d2a
Base64Utils
主要作用:编码和解码
复制代码
1
2
3
4
5
6
7
8public class Base64UtilsDemo { public static void main(String[] args) { byte[] bytes = new byte[10]; byte[] encode = Base64Utils.encode(bytes); byte[] decode = Base64Utils.decode(bytes); } }
ClassUtils
操作类的方法
CollectionUtils
封装了常见的集合操作。
DigestUtils
加密工具类
FileCopyUtils
FileSystemUtils
NumberUtils
ObjectUtils
PatternMatchUtils
ReflectionUtils
ResourceUtils
SerializationUtils
SocketUtils
StreamUtils
StringUtils
TypeUtils
最后
以上就是无辜苗条最近收集整理的关于深入浅出org.springframework.utilbackoffcomparatorconcurrentfunctionunitxml其他的全部内容,更多相关深入浅出org内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复