Guava is a very useful library, and it is quite easy to use it (partially) within the GWT client code.
First, add the guava.jar and the guava-gwt.jar libs to your project. If you are using maven, just add the following dependency to you pom.xml:
1 2 3 4 5 |
<dependency> <groupId>com.google.guava</groupId> <artifactId>guava-gwt</artifactId> <version>12.0</version> </dependency> |
For Ivy or Gradle, just have a loot at here.
Once the libs are in your classpath, you can inherit the required modules in your GWT module:
1 2 3 4 5 |
<inherits name="com.google.common.base.Base"/> <inherits name="com.google.common.math.Math"/> <inherits name="com.google.common.primitives.Primitives"/> |
or, as in my case, just add
1 |
<inherits name="com.google.common.collect.Collect"/> |
which does all of the above…
I am not going into all the guava goodies here, but…
1 2 3 |
if (!Strings.isNullOrEmpty( somebean.getSomeProperty() )) { ... } |
Â