java.util APIs
Composite Recipes
Recipes that include further recipes, often including the individual recipes below.
- Adopt
SequencedCollection - Replace
InflaterandDeflaterend()calls withclose() - Use modernized
java.utilAPIs
Recipes
- Prefer
EnumSet.of(..) - Prefer
List.of() - Prefer
List.of(..) - Prefer
List.of(..) - Prefer
List.of(..) - Prefer
Locale.of(..)overnew Locale(..) - Prefer
Map.of() - Prefer
Map.of(..) - Prefer
Map.of(..) - Prefer
Optional.isEmpty() - Prefer
Optional.isPresent() - Prefer
Predicate.not(..)over casting toPredicateand callingnegate() - Prefer
Set.of() - Prefer
Set.of(..) - Prefer
Set.of(..) - Prefer
Set.of(..) - Remove
finalize()invocations onDeflater,InflaterandZipFile - Replace
List.get(int),add(int, Object), andremove(int)withSequencedCollection*Firstand*Lastmethods - Replace
Math.random()withThreadLocalRandom.current().nextDouble() - Replace
Stream.collect(Collectors.toUnmodifiableList())withStream.toList() - Replace
filter(Optional::isPresent).map(Optional::get)withflatMap(Optional::stream) - Replace
iterator().next()withgetFirst() - Use
Reader.of(CharSequence)for non-synchronized readers - Use
getFirst()instead ofstream().findFirst().orElseThrow()