Java Idioms
Java Idioms covers modern language features and conventions for Java 17+ LTS, emphasizing records for immutable data, sealed classes for type-safe hierarchies, and pattern matching in switch expressions. The skill guides constructor injection, domain-specific exception handling, and testing with JUnit 5 and Mockito, alongside static analysis tooling to enforce code quality before commit.
Java Idioms teaches modern Java 17+ patterns including records, sealed classes, and pattern matching for idiomatic, maintainable code.
AI-generated summary based on this skill's SKILL.md
Install
irahardianto/awesome-agv/java-idioms · repository language: JavaScript
git clone https://github.com/irahardianto/awesome-agv
cp -r awesome-agv/.agents/skills/java-idioms ~/.claude/skills/java-idiomsnpx skillfed install irahardianto/awesome-agv/java-idiomsFrequently asked questions
AI-generated answers based on this skill's SKILL.md and metadata
What are Java 17+ modern coding patterns covered by Java Idioms?
Java Idioms teaches modern language features and conventions for Java 17+ LTS, emphasizing records for immutable data, sealed classes for type-safe hierarchies, and pattern matching in switch expressions. The skill guides you through constructor injection, domain-specific exception handling, and testing practices to write idiomatic Java code aligned with current best practices.
How do Java records and sealed classes improve type safety?
Java Idioms explains how records eliminate boilerplate for immutable data classes by auto-generating constructors, accessors, equals, and hashCode. Sealed classes restrict inheritance to approved subtypes, enabling exhaustive pattern matching in switch expressions. Together, they create type-safe hierarchies that the compiler can verify at compile time, reducing runtime errors.
What pattern matching switch examples does Java Idioms demonstrate?
Java Idioms covers pattern matching in switch expressions with type patterns, record patterns, and guard conditions. Examples show how to match on object types, destructure records directly in case labels, and use guards to refine matches—replacing verbose instanceof chains and casts with cleaner, more expressive switch logic.
How should Java error handling and exception hierarchies be structured?
Java Idioms guides best practices for domain-specific exception hierarchies, emphasizing checked exceptions for recoverable errors and unchecked exceptions for programming faults. The skill teaches constructor injection of error handlers, proper exception wrapping to preserve context, and clean separation of concerns so error handling logic remains testable and maintainable.
What code quality tools and static analysis does Java Idioms cover?
Java Idioms covers static analysis tooling including Spotbugs for bug detection, Checkstyle for code formatting, and SonarQube for comprehensive quality gates. The skill guides setup and configuration to enforce naming conventions, catch common pitfalls before commit, and integrate these tools into your build pipeline for consistent code standards.
How does Java Idioms teach clean, testable code with JUnit 5 and Mockito?
Java Idioms demonstrates JUnit 5 testing patterns including parameterized tests for data-driven scenarios and Mockito for isolating dependencies. The skill emphasizes constructor injection to enable easy mocking, writing focused unit tests, and using TestContainers for integration testing—ensuring your code remains maintainable and your test suite stays fast and reliable.
SKILL.md
rendered from the published skill — quoted content, verbatim
Java Idioms and Patterns
Java rewards clarity, type safety, and robust ecosystem tooling. Modern Java (17+ LTS) favors records, sealed classes, and pattern matching. Idiomatic Java = clean, readable, framework-aware.
> Scope: Java coding idioms. Test naming: .agents/rules/testing-strategy.md. Logging: @.agents/skills/logging-implementation/SKILL.md.
Modern Java Features (17+ LTS)
- Records for immutable data carriers: ```java // ✅ Concise, immutable, auto-generated equals/hashCode/toString public record CreateTaskRequest(String title, Priority priority) {}
// ❌ Verbose boilerplate POJO public class CreateTaskRequest { / getters, setters, equals, hashCode... / } ```
-
Sealed classes for constrained hierarchies:
java public sealed interface TaskResult permits Success, Failure, Pending {} public record Success(Task task) implements TaskResult {} public record Failure(String reason) implements TaskResult {} public record Pending(String taskId) implements TaskResult {} -
Pattern matching with
switch: ```java return switch (result) { case Success(var task) ->
(truncated - see the full file via the links below)
Read as markdown · JSON record · Browse the source repository
File tree — 1 file
.agents/skills/java-idioms/SKILL.md