Google Core Libraries for Java 1.5+

learn more… | top users | synonyms

3
votes
1answer
61 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
160 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
248 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
136 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
341 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
232 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
88 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
249 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
120 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
84 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
938 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
344 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
853 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
306 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 ...