Details

Language / Topic
javaJava
Category
Libraries
Source
google

Rules

balanced
- Use `ImmutableList.of()`, `ImmutableMap.of()`, `ImmutableSet.of()` for truly unmodifiable collections — they're more efficient than `Collections.unmodifiable*()`.
- Use `Preconditions.checkNotNull()`, `checkArgument()`, `checkState()` for fail-fast validation at method entry points.
- Use `Optional<T>` from Guava (or java.util) to make nullable returns explicit — never return null from methods that could return empty results.
- Use `Optional<T>` (Guava or Java) consistently. Prefer Java's `Optional` in new code.
- Use `LoadingCache` with `CacheBuilder` for automatic cache population and eviction.
- Use `Multimap`, `BiMap`, `Table` for rich collection types not available in the JDK.
- Use `Strings.isNullOrEmpty()`, `Joiner`, `Splitter` for safe string operations.