Home » Tag Archives: Google Guava (page 3)

Tag Archives: Google Guava

Using Google Guava’s Ordering API

java-logo

We’ve been playing a bit more with Google’s Guava library – what a great library! The most recent thing we used it for was to sort out the comparators for our domain objects. Here’s how. Using Apache Isis‘ JDO Objectstore, it’s good practice to make your classes implement java.lang.Comparable, and use SortedSet for the collections. You can see this in ...

Read More »

Selecting your Collections library

java-logo

Is this really something you should bother? Is there something fundamentally wrong with java.util.ArrayList and java.util.HashMap? For most of the source code out there the answer is – no; those implementations are perfectly OK. But as always, the devil is in the details. And there exist situations when either the feature set built into the Collections API is not sufficient ...

Read More »

Collection creation and Immutability with Google Guava

java-interview-questions-answers

So, thought I’d take a look at some of the collection creation patterns Guava offers, and also some of the Immutable collection types it offers. If you’ve not seen my previous posts, you may want to start here: Guava part 1 – MultiMaps Guava part 2 – BiMaps Guava part 3 – MultiSets   create methods All of Guava’s collection ...

Read More »

Google Guava Multisets

java-interview-questions-answers

Continuing this tour of Guava we get to the Multiset. I probably don’t use this as much as Multimaps or Bimaps, but it certainly does have it’s uses. So what’s a Multiset then? Well as you might be able to guess it’s a set that can hold multiple instances of the same object.         Isn’t that just ...

Read More »

ANTLR – Semantic Predicates

antlr-logo

Parsing simple grammar with antlr is simple. All you have to do is to use regular expressions to describe your language and let antlr generate lexer and parser. Parsing big or complicated languages occasionally require more, because describing them in regular expressions only can be hard or even impossible. Semantic predicates are java (or C++, or JavaScript, or …) conditions ...

Read More »

Functional Java collections

java-logo

There is a lot of functional hype these days so I would give a short overview on what is out there at least when it comes to collections in Java. Personally I like standard collections API but i some cases can be awkward and add additional verboseness. This should not be a problem in latter version of Java 8+. There ...

Read More »

Google Guava BiMaps

java-interview-questions-answers

Next up on my tour of Guava, is the BiMap, another useful collection type. It’s pretty simple really, a BiMap is simply a two way map. Inverting a Map A normal java map is a set of keys and values, and you can look up values by key, very useful, eg lets say I wanted to create a (very rudimentary) ...

Read More »

Guava Splitter vs StringUtils

java-logo

So I recently wrote a post about good old reliable Apache Commons StringUtils, which provoked a couple of comments, one of which was that Google Guava provides better mechanisms for joining and splitting Strings. I have to admit, this is a corner of Guava I’ve yet to explore. So thought I ought to take a closer look, and compare with ...

Read More »

Google Guava BloomFilter

java-logo

When the Guava project released version 11.0, one of the new additions was the BloomFilter class. A BloomFilter is a unique data-structure used to indicate if an element is contained in a set. What makes a BloomFilter interesting is it will indicate if an element is absolutely not contained, or may be contained in a set. This property of never ...

Read More »

Want to take your Java skills to the next level?

Grab our programming books for FREE!

Here are some of the eBooks you will get:

  • Advanced Java Guide
  • Java Design Patterns
  • JMeter Tutorial
  • Java 8 Features Tutorial
  • JUnit Tutorial
  • JSF Programming Cookbook
  • Java Concurrency Essentials