关于Spring中一些值得学习的工具类
Spring(和 Spring Boot) 提供了非常多实用的工具类,考虑到当前 Spring 已经成为 Java EE 开发的事实标准,学习 Spring 的工具类并将其运用到开发中是非常有意义的,特别是对于各种反射操作。下面列举了一些我认为值得学习的工具类,其中每一个一级列表项为项目名称:
spring-boot:
org.springframework.boot.context.properties.PropertyMapper(手动 Bean 映射工具)
org.springframework.boot.task.TaskExecutorBuilder(线程池 Builder)
spring-core:
org.springframework.util.function.SingletonSupplier(“惰性求值”的 Supplier)
org.springframework.util.ClassUtils(获取类的各种属性)
org.springframework.util.CollectionUtils(各种集合操作)
org.springframework.util.PatternMatchUtils(仅实现
*
的字符串匹配工具,应当比正则更高效)org.springframework.util.ReflectionUtils(各种奇妙的反射操作,相较于 ClassUtils 更倾向于去 make effect)
org.springframework.util.StopWatch(简单计时工具)
org.springframework.util.StreamUtils(IO 流操作)
org.springframework.util.StringUtils(常用字符串操作)
org.springframework.util.TypeUtils(继承关系计算)
org.springframework.core.annotation.AnnotatedElementUtils(注解获取)
spring-data-commons(这些类居然放在 spring-data 下……但一般来说都会引用 redis,因此会引用该包):
org.springframework.data.util.StreamUtils(java8 Stream 操作,终于有 zip 了呜呜呜)
org.springframework.data.util.Optionals(关于 Optional 的一些操作)
org.springframework.data.util.ParsingUtils(切分驼峰命名法字符串)