← ClaudeAtlas

language-javalisted

Java idioms — records, sealed types, virtual threads, streams, and JDK 21+ patterns. Auto-load when working with .java files, pom.xml, build.gradle, or when the user mentions Java, JVM, Spring, Maven, Gradle, records, sealed classes, or virtual threads.
lugassawan/swe-workbench · ★ 2 · Web & Frontend · score 68
Install: claude install-skill lugassawan/swe-workbench
# Java ## Records and sealed types Modern Java models data without boilerplate. ```java record Point(double x, double y) {} sealed interface Shape permits Circle, Rectangle {} record Circle(Point center, double radius) implements Shape {} record Rectangle(Point topLeft, Point bottomRight) implements Shape {} ``` - Use `record` for immutable data carriers — equals, hashCode, toString, and accessors for free. - `sealed` closes a hierarchy; exhaustive `switch` replaces `instanceof` chains. ```java double area = switch (shape) { case Circle c -> Math.PI * c.radius() * c.radius(); case Rectangle r -> Math.abs(r.bottomRight().x() - r.topLeft().x()) * Math.abs(r.bottomRight().y() - r.topLeft().y()); }; ``` ## Optional and null discipline - Return `Optional<T>` from methods that may have no result; never use it as a field or parameter type. - `Optional` is not a null check replacement — it signals "absence is a valid outcome." - Annotate parameters and fields with `@NonNull` / `@Nullable` for static analysis. ```java Optional<User> find(String id) { ... } find(id).map(User::email).orElseThrow(() -> new NotFoundException(id)); ``` ## Concurrency — virtual threads (JDK 21+) Virtual threads (Project Loom) make blocking-style IO safe at scale. ```java try (var scope = new StructuredTaskScope.ShutdownOnFailure()) { Future<User> user = scope.fork(() -> fetchUser(id)); Future<Order> order = scope.fork(() -> fetchOrder(orderId)); scop