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...
원시 유형 방지, 와일드카드에 대한 PECS(Producer Extends Consumer Super) 원칙 적용, 제한된 유형 매개변수 사용, 효과적인 제네릭 메소드 설계, 다이아몬드 연산자 활용, 유형 삭제 의미 이해, 제네릭 상속의 올바른 처리, @SafeVarargs를 통한 힙 오염 방지, 레코드, 밀봉된 유형 및 패턴 일치와 같은 최신 Java 기능과 제네릭 통합 등 제네릭 품질을 위해 Java 코드를 검토, 개선 또는 리팩토링해야 하는 경우 사용합니다. Skills-for-Java 프로젝트의 일부 출처: jabrena/cursor-rules-java.