java-language
Installation
SKILL.md
Java Language Patterns
Priority: P0 (CRITICAL)
Modern Java (21+) standards for concise, immutable, and expressive code.
Implementation Guidelines
- Records: Use record for immutable DTOs/Value Objects. Records auto-generate equals, hashCode, toString. Avoid Lombok @Data on Pojos.
- Local Variables: Use
varfor inferred types. Explicitly type interface variables. - Switch: Use Switch Expressions (->) and Pattern Matching over complex if/else chains.
- Text Blocks: Use
""" (Text Blocks)for JSON, SQL, or multi-line strings. - Pattern Matching: Use
instanceofwith pattern binding:if (obj instanceof String s). - Sealed Classes: Use sealed interface/class with permits clause for domain-driven restricted hierarchies. Switch expressions are then exhaustive switch (compiler-verified).
- Collections: Use
List.of(),Map.of(), andSet.of()for immutable collections. - Streams: Use
stream()pipelines for functional transformations. Use.toList()(Java 16+). - Optional: Utilize
Optional<T>for return types. Use.ifPresentOrElse()or.orElseThrow(). - Virtual Threads: Favor
Executors.newVirtualThreadPerTaskExecutor()for I/O-heavy workloads.
Related skills
More from hoangnguyen0403/agent-skills-standard
skill creator
Standards for creating new High-Density Agent Skills with optimal token economy.
183caveman
>
1swift swiftui
Standards for State Management, View Lifecycle, and Property Wrappers
1swift tooling
Standards for SPM, Build Configs, and Code Quality
1swift testing
Standards for XCTest, Async Tests, and Test Organization
1database-redis
Optimize Redis caching, key management, and performance. Use when implementing Redis caching strategies, managing key namespaces, or optimizing Redis performance.
1