The Guava project is a set of Java core libraries. They include collections, caching, primitives support, concurrency libraries, common annotations, string processing, I/O etc.

learn more… | top users | synonyms

3
votes
2answers
41 views

Checking if an element sastifying a condition in a list comes before another of a different condition

This is for Java 6 and uses Guava. It's a little ugly and I'm worried I missed some obvious way to do it a lot better. If there is more than one element satisfying either condition I am saying it's ...
3
votes
1answer
71 views

Functionality for automatic retry after exception

I have made the following system to automatically retry network calls if some exception is thrown. (Earlier posted on stackOverFlow, solution inspired by what @Boris answered) ...
4
votes
1answer
184 views

Receiving a JSON string response from a URL

I am using RestTemplate as my HttpClient to execute a URL while the server will return a JSON string as the response. The ...
6
votes
1answer
253 views

Calling other machines from the LinkedList if one is blocked or down

This is a follow on to : Simplifying asynchronous "executeAsync" method along with "onFailure" callback. I am using AsyncRestTemplate as my ...
2
votes
2answers
73 views

Writing an API for checked subtraction

I have to write an API for checked subtraction where the input minuend can be < 0 but subtrahend can't be < 0. I think I've covered all the cases of underflow and overflow. With given conditions ...
4
votes
1answer
138 views

Logging using function as decorator in Guava

I needed to add a logger into my flow based on FluentIterable from the Guava library. I have a lot of functions and in some cases I would like to add logging when ...
10
votes
2answers
2k views

Efficient way of sorting a List based on multiple properties using Google Guava

I'm using Google Guava 17.0 library. I have a class named AroundBust containing only two properties id of type ...
10
votes
2answers
343 views

Twitter Streaming Client - Round#2

I've been experimenting with the Twitter Streaming API and would like some critical feedback. Specifically code correctness, code smells, overall structure, and my usage of collections and queues. ...
10
votes
3answers
249 views

Solve the game “Flux”

The Program I wrote this program as an answer to a question I thought of for Programming Puzzles and Code Golf. To avoid cross-posting, I will only summarize the requirements: Solve a game in a 3x4 ...
2
votes
1answer
89 views

Decoding big text input: potential concurrency bugs?

The code here will be directly pasted from this project. Quick summary: it is related to a Stack Overflow question. So, basically, all the code below aims to implement ...
8
votes
1answer
257 views

Cache<Long, BlockingDeque<Peer>> combined with Striped<ReadWriteLock>: is it thread-safe

I've implemented PeersContainer class with all operations that I need. I need something like multimap in concurrent environment, moreover I need remove entities ...
5
votes
1answer
124 views

One-line initialisation for a constant list with all entries except one from another list

I'm looking to simplify the initialisation of the second constant, preferably to just one line. Any ideas? Anything from Guava or JDK (up to 1.6) is ok to use. ...
4
votes
2answers
86 views

Simplify finding indices of all instances of certain characters in a string

I have a string util method for finding potential "wrapping points" in a string. For example, if " " and "-" are considered ...
5
votes
1answer
998 views

Better code for converting a char to its UTF-8 percent encoding representation?

This is working code for a URI template (RFC 6570) implementation; when the character to render is not within a specific character set, it is needed to grab the UTF-8 representation of that character ...
5
votes
2answers
349 views

Helper class to memoize DateFormats application-wide

Premise Consider the following method: static String formatMyDate(Date date) { return new SimpleDateFormat("yyyy-MM-dd").format(date); } It's often ...
6
votes
1answer
883 views

Ability to forget the memoized supplier value

Guava has a feature request which is asking to provide the ability to forget memoized value on a given supplier. On top on that I needed another functionality where if during the calculation of ...
1
vote
2answers
308 views

At most one LocalDate per month in a list

I'm implementing argument check in a method where one parameter is a List of LocalDate objects (from Joda-Time). I want to make ...