Review and improve Java code using comprehensive generics best practices that enforce compile-time type safety and enable flexible, reusable APIs.
Prerequisites: Run ./mvnw compile or mvn compile before applying any change. If compilation fails, stop immediately and do not proceed — compilation failure is a blocking condition.
Core areas: Type safety (avoiding raw types, eliminating unsafe casts), code reusability (generic methods and types for multiple type contexts), API clarity (PECS wildcards — ? extends for producers, ? super for consumers), performance optimization (eliminating boxing/casting overhead), diamond operator for type inference, type erasure awareness (type tokens, factory patterns, array creation), generic inheritance...
ジェネリクスの品質を高めるために Java コードをレビュー、改善、またはリファクタリングする必要がある場合に使用します。これには、生の型の回避、ワイルドカードに対する PECS (Producer Extends Consumer Super) 原則の適用、有界型パラメータの使用、効果的なジェネリック メソッドの設計、ダイヤモンド演算子の活用、型消去の影響の理解、ジェネリック継承の適切な処理、@SafeVarargs によるヒープ汚染の防止、レコード、シール型、パターン マッチングなどの最新の Java 機能とジェネリクスの統合が含まれます。 Skills-for-Java プロジェクトの一部 ソース: jabrena/cursor-rules-java。