with one click
java-coding-style
// MANDATORY MASTER skill for Java coding style. Enforces Checkstyle (4 spaces, K&R braces), strict Javadoc templates, utility class boundaries, and functional programming patterns (In-Memory JOIN, Cursor Batching).
// MANDATORY MASTER skill for Java coding style. Enforces Checkstyle (4 spaces, K&R braces), strict Javadoc templates, utility class boundaries, and functional programming patterns (In-Memory JOIN, Cursor Batching).
[HINT] Download the complete skill directory including SKILL.md and all related files
| name | java-coding-style |
| description | MANDATORY MASTER skill for Java coding style. Enforces Checkstyle (4 spaces, K&R braces), strict Javadoc templates, utility class boundaries, and functional programming patterns (In-Memory JOIN, Cursor Batching). |
Trigger: You MUST read and follow this guide when writing, formatting, or reviewing ANY Java code to ensure structural and stylistic consistency.
BASE RULE: This project strictly enforces a combination of Google Java Style and Sun Code Conventions. When in doubt about formatting, default to Google Java Style.
. operator for chained methods (e.g., Stream API, MyBatis wrappers).{ on the same line.} on a new line.if, else, for, while (no single-line omissions).import java.util.*; is strictly forbidden).UpperCamelCase. Implementations MUST use the Impl suffix.lowerCamelCase.UPPER_SNAKE_CASE.EVERY public element MUST have Javadoc. Do not use single-line // for structural comments.
Class-Level Javadoc (Required for all Controllers, Services, Entities):
/**
* One-line description of the class responsibility
*
* @author HeHui
* @date 2026-03-31
*/
Method-Level Javadoc (Required for all public methods):
/**
* Method description
*
* @param request Request payload description
* @param accessUser Current logged-in user context
*
* @return {@link ApiResponse}<{@link Void}>
*/
Field-Level Javadoc (Required for ALL Entity/DTO/VO fields):
/**
* Account status: 0=disabled, 1=active (Must explain enum/dictionary values)
*/
private Integer accountStatus;
Inline Comments: Use // 1. Step description to divide complex logic blocks inside methods.
cn.hutool.*, org.apache.commons.*) or existing project utilities (*Util, *Helper).public final class with a private default constructor. All methods MUST be static.UserService or Entities).When writing complex data processing logic, you MUST use functional programming paradigms (Function, Consumer, BiConsumer) to abstract control flows.
Avoid nested for-loops when assembling cross-domain data. Parameterize the behavior:
public static <T, K, V> void assembleData(
List<T> source,
Function<T, K> keyExtractor,
Function<List<K>, Map<K, V>> valueLoader,
BiConsumer<T, V> resultSetter) {
// 1. Extract Keys -> 2. Load Values in Batch -> 3. Iterate and Set
}
STRICTLY PROHIBITED to load massive datasets into memory at once or use deep pagination (LIMIT offset, size). MUST use Cursor/IDX-based batch processing:
public static <T, C extends Comparable<C>> void processInBatches(
C initialCursor,
int batchSize,
BiFunction<C, Integer, List<T>> fetcher, // Query: WHERE id > cursor ORDER BY id ASC LIMIT batchSize
Function<T, C> cursorExtractor, // Extract cursor from the last element
Consumer<List<T>> batchConsumer // Consume the batch
) {
C currentCursor = initialCursor;
while (true) {
List<T> batch = fetcher.apply(currentCursor, batchSize);
if (batch == null || batch.isEmpty()) break;
batchConsumer.accept(batch);
currentCursor = cursorExtractor.apply(batch.get(batch.size() - 1));
}
}