

Also from Kynth Studios


Also from Kynth Studios


Also from Kynth Studios
12345# Java Coding Style67> This file extends [common/coding-style.md](../common/coding-style.md) with Java-specific content.89## Formatting1011- **google-java-format** or **Checkstyle** (Google or Sun style) for enforcement12- One public top-level type per file13- Consistent indent: 2 or 4 spaces (match project standard)14- Member order: constants, fields, constructors, public methods, protected, private1516## Immutability1718- Prefer `record` for value types (Java 16+)19- Mark fields `final` by default — use mutable state only when required20- Return defensive copies from public APIs: `List.copyOf()`, `Map.copyOf()`, `Set.copyOf()`21- Copy-on-write: return new instances rather than mutating existing ones2223```java24// GOOD — immutable value type25public record OrderSummary(Long id, String customerName, BigDecimal total) {}2627// GOOD — final fields, no setters28public class Order {29 private final Long id;30 private final List<LineItem> items;3132 public List<LineItem> getItems() {33 return List.copyOf(items);34 }35}36```3738## Naming3940Follow standard Java conventions:41- `PascalCase` for classes, interfaces, records, enums42- `camelCase` for methods, fields, parameters, local variables43- `SCREAMING_SNAKE_CASE` for `static final` constants44- Packages: all lowercase, reverse domain (`com.example.app.service`)4546## Modern Java Features4748Use modern language features where they improve clarity:49- **Records** for DTOs and value types (Java 16+)50- **Sealed classes** for closed type hierarchies (Java 17+)51- **Pattern matching** with `instanceof` — no explicit cast (Java 16+)52- **Text blocks** for multi-line strings — SQL, JSON templates (Java 15+)53- **Switch expressions** with arrow syntax (Java 14+)54- **Pattern matching in switch** — exhaustive sealed type handling (Java 21+)5556```java57// Pattern matching instanceof58if (shape instanceof Circle c) {59 return Math.PI * c.radius() * c.radius();60}6162// Sealed type hierarchy63public sealed interface PaymentMethod permits CreditCard, BankTransfer, Wallet {}6465// Switch expression66String label = switch (status) {67 case ACTIVE -> "Active";68 case SUSPENDED -> "Suspended";69 case CLOSED -> "Closed";70};71```7273## Optional Usage7475- Return `Optional<T>` from finder methods that may have no result76- Use `map()`, `flatMap()`, `orElseThrow()` — never call `get()` without `isPresent()`77- Never use `Optional` as a field type or method parameter7879```java80// GOOD81return repository.findById(id)82 .map(ResponseDto::from)83 .orElseThrow(() -> new OrderNotFoundException(id));8485// BAD — Optional as parameter86public void process(Optional<String> name) {}87```8889## Error Handling9091- Prefer unchecked exceptions for domain errors92- Create domain-specific exceptions extending `RuntimeException`93- Avoid broad `catch (Exception e)` unless at top-level handlers94- Include context in exception messages9596```java97public class OrderNotFoundException extends RuntimeException {98 public OrderNotFoundException(Long id) {99 super("Order not found: id=" + id);100 }101}102```103104## Streams105106- Use streams for transformations; keep pipelines short (3-4 operations max)107- Prefer method references when readable: `.map(Order::getTotal)`108- Avoid side effects in stream operations109- For complex logic, prefer a loop over a convoluted stream pipeline110111## References112113See skill: `java-coding-standards` for full coding standards with examples.114See skill: `jpa-patterns` for JPA/Hibernate entity design patterns.115
One repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| ThanhTrunggDEV/DontBeLazy.cursor/rules/zh-agents.mdc · 6 | Cursor rules | no sections | 50/100 | 14 days ago | |
| ThanhTrunggDEV/DontBeLazy.cursor/rules/zh-patterns.mdc · 6 | Cursor rules | api | 30/100 | 14 days ago | |
| ThanhTrunggDEV/DontBeLazy.agent/AGENTS.md · 6 | AGENTS.md | buildteststylearch+4 | 77/100 | 14 days ago | |
| ThanhTrunggDEV/DontBeLazy.cursor/AGENTS.md · 6 | AGENTS.md | buildteststylearch+4 | 77/100 | 14 days ago | |
| ThanhTrunggDEV/DontBeLazy.cursor/rules/common-agents.mdc · 6 | Cursor rules | agent-behaviour | 50/100 | 14 days ago | |
| ThanhTrunggDEV/DontBeLazy.cursor/rules/common-code-review.mdc · 6 | Cursor rules | styletesting-strategygitsecurity+3 | 65/100 | 14 days ago | |
| ThanhTrunggDEV/DontBeLazy.cursor/rules/common-coding-style.mdc · 6 | Cursor rules | style | 54/100 | 14 days ago | |
| ThanhTrunggDEV/DontBeLazy.cursor/rules/common-development-workflow.mdc · 6 | Cursor rules | gitagent-behaviour | 39/100 | 14 days ago | |
| ThanhTrunggDEV/DontBeLazy.cursor/rules/common-git-workflow.mdc · 6 | Cursor rules | lint-formatgitagent-behaviour | 43/100 | 14 days ago | |
| ThanhTrunggDEV/DontBeLazy.cursor/rules/common-hooks.mdc · 6 | Cursor rules | styletypessecuritydo-not | 36/100 | 14 days ago | |
| ThanhTrunggDEV/DontBeLazy.cursor/rules/common-patterns.mdc · 6 | Cursor rules | lint-formatstyleapi | 52/100 | 14 days ago | |
| ThanhTrunggDEV/DontBeLazy.cursor/rules/common-performance.mdc · 6 | Cursor rules | buildperformance | 48/100 | 14 days ago | |
| ThanhTrunggDEV/DontBeLazy.cursor/rules/common-security.mdc · 6 | Cursor rules | security | 39/100 | 14 days ago | |
| ThanhTrunggDEV/DontBeLazy.cursor/rules/common-testing.mdc · 6 | Cursor rules | testtesting-strategyagent-behaviour | 34/100 | 14 days ago | |
| ThanhTrunggDEV/DontBeLazy.cursor/rules/cpp-coding-style.mdc · 6 | Cursor rules | lint-formatstyle | 52/100 | 14 days ago | |
| ThanhTrunggDEV/DontBeLazy.cursor/rules/cpp-hooks.mdc · 6 | Cursor rules | buildlint-formatdeployment | 60/100 | 14 days ago | |
| ThanhTrunggDEV/DontBeLazy.cursor/rules/cpp-patterns.mdc · 6 | Cursor rules | style | 54/100 | 14 days ago | |
| ThanhTrunggDEV/DontBeLazy.cursor/rules/cpp-security.mdc · 6 | Cursor rules | securityperformancedo-not | 73/100 | 14 days ago | |
| ThanhTrunggDEV/DontBeLazy.cursor/rules/cpp-testing.mdc · 6 | Cursor rules | testtesting-strategy | 55/100 | 14 days ago | |
| ThanhTrunggDEV/DontBeLazy.cursor/rules/csharp-coding-style.mdc · 6 | Cursor rules | lint-formatstyletypes | 66/100 | 14 days ago |
Same format, overlapping stack, ranked by quality.
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| TechSquidTV/Hermes.cursor/rules/10-hermes-api.mdc · 45 | Cursor rules | testlint-formatstylearch+5 | 100/100 | 14 days ago | |
| hiromaily/go-crypto-wallet.cursor/rules/typescript.mdc · 126 | Cursor rules | setupbuildtestlint-format+6 | 100/100 | 14 days ago | |
| dodgecfr/combatfilms-webapp.cursor/rules/frontend.mdc · 0 | Cursor rules | setuptestlint-formatstyle+7 | 99/100 | 14 days ago | |
| deifos/clipmira-subtitles.cursor/rules/frontend.mdc · 1 | Cursor rules | setuptestlint-formatstyle+7 | 99/100 | 14 days ago | |
| markstev/mark-starter.cursor/rules/frontend.mdc · 0 | Cursor rules | setuptestlint-formatstyle+6 | 99/100 | 14 days ago | |
| Allymahmoud/case-intake-platform.cursor/rules/frontend.mdc · 0 | Cursor rules | setuptestlint-formatstyle+7 | 99/100 | 14 days ago | |
| langflow-ai/langflow.cursor/rules/docs_development.mdc · 153k | Cursor rules | setupbuildtestlint-format+7 | 97/100 | 14 days ago | |
| TechSquidTV/Hermes.cursor/rules/20-hermes-api-tests.mdc · 45 | Cursor rules | teststyletesting-strategysecurity+3 | 97/100 | 14 days ago |
A badge carrying the measured quality of the strongest agent config file in this repository, out of 100. It reads from this index every time somebody loads your page, so it changes when the measurement changes and there is nothing to keep up to date. Free, no account, and the value is not something you or we can set by hand.
[](https://rulestack.kynth.studio/configs/thanhtrunggdev-dontbelazy-cursor-rules-java-coding-style)Would rather not hotlink us? Every badge is also served in shields.io’s endpoint schema, so shields renders the image and your readers never talk to our domain:
Published by Toolproof, the masthead over this index and eight others. The method behind the number is at toolproof.kynth.studio/methodology, and the whole thing is readable as JSON with no key at /api.