27.11.11

Two Generally Useful Guava Annotations | Javalobby

The Guava project contains several of Google's core libraries that we rely on in our Java-based projects: collections, caching, primitives support, concurrency libraries, common annotations, string processing, I/O, and so forth.
The latest release is 10.0.1, released October 10, 2011.

Guava Common Annotations


Annotation Types Summary
BetaSignifies that a public API (public class, method or field) is subject to incompatible changes, or even removal, in a future release.
GwtCompatibleThe presence of this annotation on a type indicates that the type may be used with the Google Web Toolkit (GWT).
GwtIncompatibleThe presence of this annotation on a method indicates that the method may not be used with the Google Web Toolkit (GWT), even though its type is annotated as GwtCompatible and accessible in GWT.
VisibleForTestingAn annotation that indicates that the visibility of a type or member has been relaxed to make the code testable.

From Two Generally Useful Guava Annotations | Javalobby

  • The last two are specific to use with GWT (GwtCompatible and GwtIncompatible)
  • But the former two can be useful in a more general context. (Beta, and VisibleForTesting)

Conclusion by Dustin Marx

Guava provides two annotations that are not part of the standard Java distribution, but cover situations that we often run into during Java development. The @Beta annotation indicates a construct in a public API that may be changed or removed. The @VisibleForTesting annotation advertises to other developers (or reminds the code's author) when a decision was made for relaxed visibility to make testing possible or easier.

No comments: