141-java-refactoring-with-modern-features

Featured

Use when you need to refactor Java code to adopt modern Java features (Java 8+) — including migrating anonymous classes to lambdas, replacing Iterator loops with Stream API, adopting Optional for null safety, switching from legacy Date/Calendar to java.time, using collection factory methods, applying text blocks, var inference, or leveraging Java 25 features like flexible constructor bodies and module import declarations. This should trigger for requests such as Review Java code for modern Java development; Apply best practices for modern Java development in Java code; Modernize Java code with records pattern matching or switch expressions; Replace legacy idioms with modern Java features; Adopt Java 8+ language features safely. Part of Plinth Toolkit

Code & Development 423 stars 89 forks Updated 3 days ago Apache-2.0

Install

View on GitHub

Quality Score: 93/100

Stars 20%
87
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# Modern Java Development Guidelines (Java 8+) Identify and apply modern Java (Java 8+) refactoring opportunities to improve readability, maintainability, and performance. **What is covered in this Skill?** - Lambda expressions and method references (over anonymous classes) - Stream API for declarative collection processing - `Optional` for null-safe APIs - `java.time` API (replacing `Date`/`Calendar`) - Default interface methods, `var` type inference - Unmodifiable collection factory methods (`List.of()`, `Set.of()`, `Map.of()`) - Text blocks for multi-line strings - Java 25 Flexible Constructor Bodies (JEP 513) - Java 25 Module Import Declarations (JEP 511) **Scope:** The reference is organized by examples (good/bad code patterns) for each core area. Apply recommendations based on applicable examples. ## Constraints Before applying any modern Java refactoring, ensure the project compiles. If compilation fails, stop immediately — do not proceed until the project compiles successfully. After applying improvements, run full verification. - **MANDATORY**: Run `./mvnw compile` or `mvn compile` before applying any changes - **SAFETY**: If compilation fails, stop immediately — do not proceed until the project compiles successfully - **VERIFY**: Run `./mvnw clean verify` or `mvn clean verify` after applying improvements - **BEFORE APPLYING**: Read the reference for detailed good/bad examples, constraints, and safeguards for each modern Java feature - **EDGE CASE**: If reques...

Details

Author
jabrena
Repository
jabrena/plinth
Created
1 years ago
Last Updated
3 days ago
Language
Java
License
Apache-2.0

Integrates with

Bundled in these plugins

Similar Skills

Semantically similar based on skill content — not just same category

Code & Development Listed

java-refactor

Suggests and applies version-gated Java refactorings. Use when user asks to "refactor this", "clean up this code", "modernize this Java", "simplify this", "extract method", "improve this class", or "make this more idiomatic".

1 Updated today
limited-grisaille833
AI & Automation Featured

142-java-functional-programming

Use when you need to apply functional programming principles in Java — including writing immutable objects and Records, pure functions, functional interfaces, lambda expressions, Stream API pipelines, Optional for null safety, function composition, higher-order functions, pattern matching for instanceof and switch, sealed classes/interfaces for controlled hierarchies, Stream Gatherers for custom operations, currying/partial application, effect boundary separation, and concurrent-safe functional patterns. This should trigger for requests such as Improve the code with Functional Programming; Apply Functional Programming; Refactor the code with Functional Programming; Refactor Java code to use streams or Optionals safely; Improve immutability and pure functions in Java. Part of Plinth Toolkit

423 Updated 3 days ago
jabrena
Code & Development Featured

145-java-refactoring-high-performance

Use when you need to refactor Java code for high performance — including memory/allocation reduction, CPU hot-path optimization, and syntax/API/control-flow improvements. This should trigger for requests such as Review Java code for high performance; Optimize Java hot path; Reduce Java allocations; Improve Java latency/throughput. Part of Plinth Toolkit

423 Updated 3 days ago
jabrena