zookeeper-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ted Dunning <ted.dunn...@gmail.com>
Subject guava dependency
Date Mon, 04 Jul 2011 03:16:42 GMT

At the zookeeper contributor meeting after the Hadoop Summit, the question
came up about whether we should introduce a dependency on the Guava library
from Google.

That led to a question of what Guava really is.

Not that I would like to try to replace the very nice presentations that are
around, but here is a list of some of the constructs that I use from Guava
all the time:


   - splitters and joiners (that work right)

          final static Splitter onWhiteSpace =
Splitter.on(CharMatcher.WHITESPACE);

    - type inferencing factory methods

          Map<String, String> dictionary = Maps.newHashMap();
          Map<String, Integer> table = ImmutableMap.of("abc", 1, "def", 2);

     - orderings that make sense and do cool things

          Ordering.natural().immutableSortedCopy(iterable)

     - reading a resource all in a gulp (note the predefined charset that
never requires a throw):

           Resources.readLines(Resources.getResource("foo.csv"),
Charsets.UTF-8)

It can take a bit of time to realize how useful Guava can be and it is
difficult to understand at first glance how deep the design thinking was
that created it, but after getting used to Guava, programming without it is
painful.

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message