Tuesday, 17 January 2012

Guava library

Some useful classes and methods from Guava library:
  • Charset.UTF_8, Charsets.UTF_16, ... - helpers for creating Charset class
  • Defaults.defaultValue(Class) - default value of given class
  • ImmutableSet, ImmutableList, ImmutableMap - builders for collections types f.e. List list = ImmutableList.of("1","2");
  • Joiner - for concatenating Strings
  • Strings.emptyToNull, Strings.nullToEmpty - String converters
  • Objects.equal(val1,val2) - returns if objects are equal
  • Objects.hashCode(...) - generates hashCode from list of objects
  • Objects.toStringHelper - utility for creating toString methods
  • Preconditions - methods for checking conditions on objects, if not meet then an Exception is thrown
  • Files - utility for file operations. copy (coping files), equals (files content is equal), getCheckSum (file check sum), getFileExtension, move (moving file in the file system), newReader (creates reader object on the file), newWriter (creates writer object on the file), readLines (returns list of strings), toBytesArray (array of bytes for file), toString (whole file as string), touch (touch on file in filesystem)
  • Closeables.closeQuietly - close stream without throwing IOException
  • Flushables.flushQuietly - flush without throwing IOException
  • BiMapsm - bidirectional map
  • MultiMaps, MultiLists - many implementations of multimaps multilists
  • Hashing, HashFunction - utilities for creating hash functions, usage of md5 calculation
  • IntMath, LogMath, DoubleMath, BigIntegerMath - operations tested for overflow, using hardware details for efficiency
  • CacheBuilder - for easy creating caches that expire after given time, amount, with other parameters
  • Cache.stats - for getting statistics of the cache object

More details on Guava library home page: http://code.google.com/p/guava-libraries/

No comments: