Introduction to Guava

Guava , started originally in 2007 as the "Google Collection Library", which provided utilities for working with Java collections. It has evolved into an essential toolkit for Java developers. There are multiple utilities/features for strings, collections, reflection, concurrency, etc. It has Functional interface which incorporates functional programing into Java, Supplier interface helps with creational pattern and many more cool components. But Guava is just more than that. It's about writing a good code and making it more resilient and concise.

Guava is being used by millions of developers and it has a staggering 280,000 plus test cases which makes it is one of the most reliable and well tested code developers can reuse without reinventing the wheel. Really good developers will look for an established library to help with a problem before starting to write their own. Guava can improve the quality of your code as well as make your job a little easier.

 Using Guava with Gradle.

All the examples are using Gradle as the build tool.
Gradle is the next evolutionary step in JVM-based build tools. It draws on lessons learned from established tools such as Ant and Maven and takes their best ideas to the next level. Following a build-by-convention approach, Gradle allows for declaratively modeling your problem domain using a powerful and expressive domain-specific language (DSL) implemented in Groovy instead of XML. Because Gradle is a JVM native, it allows you to write custom logic in the language you're most comfortable with, be it Java or Groovy.

Please follow the instructions on how to setup gradle from the following url.

Creating a new Java Project using Gradle.

  1. Create new folder
  2. execute command: gradle init --type java-library (This will create a java project structure automatically)
  3. Add gradle eclipse plugin to the build.gradle file.
  4. Add the following dependency to build.gradle file.
                            compile group: 'com.google.guava', name: 'guava', version: '19.0'
  1. execute command: gradle eclipse (This will convert the project to an eclipse project)
  2. Import project to eclipse and start development.


Comments