Package com.hubspot.immutables.style
Annotation Type HubSpotImmutableStyle
-
@Target({PACKAGE,TYPE}) @Retention(CLASS) public @interface HubSpotImmutableStyle
This style is preferred overHubSpotStylebecause it enforces use of guava's Immutable* collection types. Using these types in immutables is more efficient than using JDK default collections, because immutable collections allow us to make copies of immutables without copying whole collections and avoid copies when callingbuild()on immutable builders.
This style does however introduce some behavioral differences to the standard style, the most major of these being:- You must define methods as returning `ImmutableList` etc. not `List`
- Inserting duplicate map keys will throw an exception.
- The returned values from various getters is actually immutable, and mutations will throw
UnsupportedOperationException