笔记篇-Google Guava快速入门
简介
Guava是一种基于开源的Java库,其中包含谷歌正在由他们很多项目使用的很多核心库。这个库是为了方便编码,并减少编码错误。这个库提供用于集合,缓存,支持原语,并发性,常见注解,字符串处理,I/O和验证的实用方法。
特点
- 标准化 - Guava库是由谷歌托管。
- 高效 - 可靠,快速和有效的扩展JAVA标准库
- 优化 -Guava库经过高度的优化。
入门
1 |
|
教程
Guava 的 Java 反射机制工具类
基本工具
Make using the Java language more pleasant.
- Using and avoiding null:
null
can be ambiguous, can cause confusing errors, and is sometimes just plain unpleasant. Many Guava utilities reject and fail fast on nulls, rather than accepting them blindly. - Preconditions: Test preconditions for your methods more easily.
- Common object methods: Simplify implementing
Object
methods, likehashCode()
andtoString()
. - Ordering: Guava’s powerful “fluent
Comparator
“ class. - Throwables: Simplify propagating and examining exceptions and errors.
集合
Guava’s extensions to the JDK collections ecosystem. These are some of the most mature and popular parts of Guava.
- Immutable collections, for defensive programming, constant collections, and improved efficiency.
- New collection types, for use cases that the JDK collections don’t address as well as they could: multisets, multimaps, tables, bidirectional maps, and more.
- Powerful collection utilities, for common operations not provided in
java.util.Collections
. - Extension utilities: writing a
Collection
decorator? ImplementingIterator
? We can make that easier.
图表
a library for modeling graph
- structured data, that is, entities and the relationships between them. Key features include:
- Graph: a graph whose edges are anonymous entities with no identity or information of their own.
- ValueGraph: a graph whose edges have associated non-unique values.
- Network: a graph whose edges are unique objects.
- Support for graphs that are mutable and immutable, directed and undirected, and several other properties.
缓存
缓存: Local caching, done right, and supporting a wide variety of expiration behaviors.
函数式编程
- 函数式编程: Used sparingly, Guava’s functional idioms can significantly simplify code.
并发
- 并发: Powerful, simple abstractions to make it easier to write correct concurrent code.
- ListenableFuture: Futures, with callbacks when they are finished.
- Service: Things that start up and shut down, taking care of the difficult state logic for you.
字符操作
- 字符操作: A few extremely useful string utilities: splitting, joining, padding, and more.
原生类型
- 原生类型: operations on primitive types, like
int
andchar
, not provided by the JDK, including unsigned variants for some types.
区间
- 区间: Guava’s powerful API for dealing with ranges on
Comparable
types, both continuous and discrete.
I/O
- I/O: Simplified I/O operations, especially on whole I/O streams and files, for Java 5 and 6.
哈希
- 哈希: Tools for more sophisticated hashes than what’s provided by
Object.hashCode()
, including Bloom filters.
事件总线
- 事件总线: Publish-subscribe-style communication between components without requiring the components to explicitly register with one another.
数学运算
- 数学运算: Optimized, thoroughly tested math utilities not provided by the JDK.
反射
- 反射: Guava utilities for Java’s reflective capabilities.
参考
笔记篇-Google Guava快速入门
https://mikeygithub.github.io/2021/04/11/yuque/笔记篇-Google Guava快速入门/