Guava introduces some new collection types that are not available in JDK, but are very useful. All these new collection types can be smoothly integrated with the collection in JDK. The Guava set accurately implements the JDK-defined interfaces. The new set defined in Guava includes:MultisetSortedMultisetMultimapListMultimapSetMultimapBiMapClassToInstanceMapTable
business are increased, and the code you write becomes less readable. Then we can consider using the bimap in guava. Bimap Bimap is very simple to use, for the above use of the scenario, we can use a very simple code to achieve: @Test public void Bimaptest () {bimap Mandatory uniqueness of BIMAP data When using Bimap, value uniqueness is required. If value is repeated, an error is thrown: java.lang.IllegalArgumentException, for example: @Test
Table
When we need data structures with Multiple indexes, we can only use this ugly Map
Output:
{A=A2, B=B2, C=1=B1, 2=B2, 3=1={A=A1, B=B1, C=C1}, 2={A=A2, B=B2, C=C2}, 3={A=A3, B=B3, C=={1=A1, 2=A2, 3=A3}, B={1=B1, 2=B2, 3=B3}, C={1=C1, 2=C2, 3=
Table View:RowMap () returns a Map Row (r) returns a non-null Map The column-related methods include columnMap (), columnKeySet (), and column (c ). (Column-based operations are less efficient than Row-based operations)The returned result of cellSet
assertTrue(byLengthOrdering.reverse().isOrdered(list));
OrderingIs the "smooth version" of Guava"ComparatorIt is used to build advanced comparator and apply comparator to various collections ).
OrderingThe instance is just a special
Ordering
Natural ()
Natural sorting(Natural ordering ).
UsingToString ()
The return values of toString () are ordered alphabetically
In daily development, we sometimes need to construct a Map
Note: It is too difficult to implement
Multimap
The Multimap of Guava provides a data structure that conveniently maps a key to multiple values. This allows us to easily and elegantly implement the complex data structure above, so that we can focus on implementing business logic rather than on the data structure, next, let's take a look at the knowledge points of Multimap.
The above code
1. Introduction
The Guava project contains a number of core libraries that are heavily reliant on Google's Java projects, including collections, caching, primitives support, concurrency libraries, common Annotations, string processing, I/O, and so on. These high quality APIs can make your Java code more elegant and concise, making your work easier and more enjoyable.
2. Official Information
Official home: Http://code.google.com/p/
method of load value based on the key value. The callable approach is more flexible, allowing you to specify when you get it.The difference between 2.Ehcache and guava CacheRecently in the context of some cache transformation, there are some lessons to be summarized:Cached version:
ehcache:2.8.3guava:17.0
Ehcache support persistent to local disk, guava can not;
Ehcache has a rea
ObjectiveThe Guava class library has been briefly introduced in the Front (blog: Java code Elegant way-guava (with the relevant jar package download), the following is a brief introduction to the operation of the Set,map,list collection of the use of tools, learning to use these tools flexibly, will use our development, more time-saving, code robustness and rea
Translated from Google Guava CacheThis Post was a continuation of my series on Google guava, this time covering guava Cache. Guava Cache offers more flexibility and power than either a HashMap or concurrenthashmap, but was not as heavy as using EHC Ache or Memcached (or robust for the matter, as
Tags: ALT monitor IMG LSE based on Not for Call () Builder projectGuava is an open source Java framework for Google, and its GitHub address is Https://github.com/google/guava. The Guava project contains several core libraries that are widely relied on by Google's Java projects, such as: collections [Collections], cache [caching], native type support [primitives supports], concurrent libraries [concurrency L
The following documents are organized from the network1. Introduction to Google guava
Introduction
The guava project contains several core libraries that are widely relied on by Google's Java projects. For example: set [collections], cache [caching], native support [primitives support], concurrent Library [concurrency libraries], General annotation [common annotations], string processing [string processing
Google Guava Official tutorial (Chinese version)Link Translator: Shenyan, lolli tree, He Yixin, Vouzou proofreading : Fang FeiIntroductionThe Guava project contains several core libraries that are widely relied on by Google's Java projects, such as: collections [Collections], cache [caching], native type support [primitives supports], concurrent libraries [Concurrency Lib Raries], common annotations [common
This blog reference from: http://ifeve.com/google-guava-cachesexplained/
Guava's maven dependency:
Guava Cache Application Scenario:
It is quite useful to be slow in many scenarios. For example, the cost of calculating or retrieving a value is high, and you should consider using caching when you need to get a value more than once for the same input.
Guava cache
Http://www.cnblogs.com/snidget/archive/2013/02/05/2893344.html1, outlineLet's familiarize ourselves with the melon and experience some of its APIs, divided into the following sections:
Introduction
Guava Collection API
Guava Basic Utilities
IO API
Cache API
2, choose a baby for God's horse?
Eva is the ice cream on the Java API Cake (essence)
Efficient and well-desi
Guava provides us with the event Bus Eventbus library in Guava-libraries, which is an implementation of the event release subscription model, allowing us to decouple the design of our modules and domain boundaries in domain-driven design (DDD) with the weak reference nature of events.No more nonsense, straight to the guava Eventbus theme. First
these methods is not really immutable.3. Inefficient: Because the nature of the data structure it returns is still the original collection class, its operating overhead, including the concurrent modification check, the hash table in the additional data space is the same as the original collection. Immutable collection of GuavaGuava provides a simple and convenient implementation of the immutable version of the standard collection class in the JDK, as well as the immutable implementation of som
Official website: https://github.com/rholder/guava-retryingMaven:https://mvnrepository.com/artifact/com.github.rholder/guava-retryingThe following examples are spring boot-based, but can be used for spring projects. Currently the latest version is 2.0.0.Integration steps:Pom Introduction: https://mvnrepository.com/artifact/com.github.rholder/guava-retrying
1, outlineLet's familiarize ourselves with the melon and experience some of its APIs, divided into the following sections:
Introduction
Guava Collection API
Guava Basic Utilities
IO API
Cache API
2, choose a baby for God's horse?
Eva is the ice cream on the Java API Cake (essence)
Efficient and well-designed API.
Designed, implemented, and used by Google's deve
Chance Contact Guava, for me this small white, Google's things are of course tall on the, so holding learning (installed) the mentality of learning (forced), on the Internet to learn from the predecessors. Of course, I learn guava mainly for a few purposes, the first of course is to think about whether guava can be applied to their own weekday code, if the
value. This time the threadT2when you come in, you get Futureobject, if no value is OK, this is the object's reference, etc.Futuretaskafter execution, in the passageGetreturn. We solve the problem of high concurrency access cache, can be recycled elements of these, are not, easy to cause memory overflow,Google Guava cache in these issues are very good, and then we introduce. three. Introduction and application of Google
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.