zoukankan      html  css  js  c++  java
  • Guava User Guide

    The Guava project contains several of Google's core libraries that we rely on in our Java-based projects: collections, caching, primitives support, concurrency libraries, common annotations, string processing, I/O, and so forth. Each of these tools really do get used every day by Googlers, in production services.

    But trawling through Javadoc isn't always the most effective way to learn how to make best use of a library. Here, we try to provide readable and pleasant explanations of some of the most popular and most powerful features of Guava.

    This wiki is a work in progress, and parts of it may still be under construction.

    • Basic utilities: Make using the Java language more pleasant.
      • Using and avoiding nullnull 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, like hashCode() and toString().
      • Ordering: Guava's powerful "fluent Comparator" class.
      • Throwables: Simplify propagating and examining exceptions and errors.
    • Collections: 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? Implementing Iterator? We can make that easier.
    • Graphs: 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.
    • Caches: Local caching, done right, and supporting a wide variety of expiration behaviors.
    • Functional idioms: Used sparingly, Guava's functional idioms can significantly simplify code.
    • Concurrency: 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.
    • Strings: A few extremely useful string utilities: splitting, joining, padding, and more.
    • Primitives: operations on primitive types, like int and char, not provided by the JDK, including unsigned variants for some types.
    • Ranges: Guava's powerful API for dealing with ranges on Comparable types, both continuous and discrete.
    • I/O: Simplified I/O operations, especially on whole I/O streams and files, for Java 5 and 6.
    • Hashing: Tools for more sophisticated hashes than what's provided by Object.hashCode(), including Bloom filters.
    • EventBus: Publish-subscribe-style communication between components without requiring the components to explicitly register with one another.
    • Math: Optimized, thoroughly tested math utilities not provided by the JDK.
    • Reflection: Guava utilities for Java's reflective capabilities.
    • Tips: Getting your application working the way you want it to with Guava.

    The Guava project contains several of Google's core libraries that we rely on in our Java-based projects: collections, caching, primitives support, concurrency libraries, common annotations, string processing, I/O, and so forth. Each of these tools really do get used every day by Googlers, in production services.

    But trawling through Javadoc isn't always the most effective way to learn how to make best use of a library. Here, we try to provide readable and pleasant explanations of some of the most popular and most powerful features of Guava.

    This wiki is a work in progress, and parts of it may still be under construction.

    • Basic utilities: Make using the Java language more pleasant.
      • Using and avoiding nullnull 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, like hashCode() and toString().
      • Ordering: Guava's powerful "fluent Comparator" class.
      • Throwables: Simplify propagating and examining exceptions and errors.
    • Collections: 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? Implementing Iterator? We can make that easier.
    • Graphs: 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.
    • Caches: Local caching, done right, and supporting a wide variety of expiration behaviors.
    • Functional idioms: Used sparingly, Guava's functional idioms can significantly simplify code.
    • Concurrency: 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.
    • Strings: A few extremely useful string utilities: splitting, joining, padding, and more.
    • Primitives: operations on primitive types, like int and char, not provided by the JDK, including unsigned variants for some types.
    • Ranges: Guava's powerful API for dealing with ranges on Comparable types, both continuous and discrete.
    • I/O: Simplified I/O operations, especially on whole I/O streams and files, for Java 5 and 6.
    • Hashing: Tools for more sophisticated hashes than what's provided by Object.hashCode(), including Bloom filters.
    • EventBus: Publish-subscribe-style communication between components without requiring the components to explicitly register with one another.
    • Math: Optimized, thoroughly tested math utilities not provided by the JDK.
    • Reflection: Guava utilities for Java's reflective capabilities.
    • Tips: Getting your application working the way you want it to with Guava.
  • 相关阅读:
    .NET微信网页开发之JS-SDK使用步骤和配置信息timestamp(时间戳),nonceStr(随机串),signature(签名),access_token(接口调用凭据)的生成获取讲解
    .NET项目中NLog的配置与使用
    ASP.NET MVC中使用jQuery Ajax通过FormData对象异步提交图片文件到服务端保存并返回保存的图片路径
    Linux CentOS上安装 MySQL 8.0.16
    微信小程序开发之多图片上传+.NET WebAPI后端服务保存图片资源
    MySQL 查询重复数据,删除重复数据保留id最小的一条作为唯一数据
    .NET轻松实现支付宝服务窗网页授权并获取用户相关信息
    .NET微信网页开发之通过UnionID机制,解决用户在不同公众号,或在公众号、移动应用之间帐号统一问题
    Navicat远程连接MySQL 提示1045
    Vs Code推荐安装插件
  • 原文地址:https://www.cnblogs.com/lnas01/p/11254744.html
Copyright © 2011-2022 走看看