{"id":"cee6ad6e-5d6b-4155-90c9-2e2e0638212f","shortId":"sJWURC","kind":"skill","title":"142-java-functional-programming","tagline":"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","description":"# Java Functional Programming rules\n\nIdentify and apply functional programming principles in Java to improve immutability, expressiveness, and maintainability.\n\n**What is covered in this Skill?**\n\n- Immutable objects and Records (JEP 395)\n- Pure functions free of side effects\n- Functional interfaces: `Function`, `Predicate`, `Consumer`, `Supplier`, custom `@FunctionalInterface`\n- Lambda expressions and method references\n- Stream API: filter/map/reduce pipelines, parallel streams, `toUnmodifiable*` collectors\n- `Optional` idiomatic usage: `map`/`flatMap`/`filter`/`orElse*` over `isPresent()`+`get()`\n- Function composition: `andThen`/`compose`\n- Higher-order functions: memoization, currying, partial application\n- Pattern Matching for `instanceof` and `switch` (Java 21)\n- Sealed classes and interfaces (Java 17) for exhaustive domain hierarchies\n- Switch Expressions (Java 14), Stream Gatherers (JEP 461)\n- Effect-boundary separation: side effects at edges, pure core logic\n- Immutable collections: `List.of()`, `Collectors.toUnmodifiableList()`\n\n**Scope:** The reference is organized by examples (good/bad code patterns) for each core area. Apply recommendations based on applicable examples.\n\n## Constraints\n\nBefore applying any functional programming changes, ensure the project compiles. If compilation fails, stop immediately — do not proceed until the project compiles successfully. Verify that maven-compiler-plugin source/target supports the Java features being used.\n\n- **MANDATORY**: Run `./mvnw compile` or `mvn compile` before applying any changes\n- **SAFETY**: If compilation fails, stop immediately — do not proceed until the project compiles successfully\n- **VERIFY**: Verify maven-compiler-plugin source/target supports the Java features being used\n- **VERIFY**: Run `./mvnw clean verify` or `mvn clean verify` after applying improvements\n- **BEFORE APPLYING**: Read the reference for detailed good/bad examples, constraints, and safeguards for each functional programming pattern\n- **EDGE CASE**: If request scope is ambiguous, stop and ask a clarifying question before applying changes\n- **EDGE CASE**: If required inputs, files, or tooling are missing, report what is missing and ask whether to proceed with setup guidance\n\n## When to use this skill\n\n- Improve the code with Functional Programming\n- Apply Functional Programming\n- Refactor the code with Functional Programming\n\n## Workflow\n\n1. **Compile project before functional refactoring**\n\nRun `./mvnw compile` or `mvn compile` and stop immediately if compilation fails.\n\n2. **Confirm Java feature compatibility**\n\nVerify maven-compiler-plugin source/target supports the functional features planned for adoption.\n\n3. **Read functional-programming reference and assess code**\n\nRead `references/142-java-functional-programming.md` and identify opportunities for immutability, pure functions, and functional composition.\n\n4. **Apply functional programming improvements**\n\nImplement selected functional refactorings while keeping side effects at boundaries.\n\n5. **Verify with full build**\n\nRun `./mvnw clean verify` or `mvn clean verify` after applying improvements.\n\n## Reference\n\nFor detailed guidance, examples, and constraints, see [references/142-java-functional-programming.md](references/142-java-functional-programming.md).","tags":["142","java","functional","programming","cursor","rules","jabrena","agent-skills","ai-skills","claude","claude-code","claude-code-skills"],"capabilities":["skill","source-jabrena","skill-142-java-functional-programming","topic-agent-skills","topic-ai-skills","topic-claude","topic-claude-code","topic-claude-code-skills","topic-claude-code-subagents","topic-claude-skills","topic-cursor-agent","topic-cursor-ai","topic-cursor-skills","topic-cursorai","topic-github-copilot"],"categories":["cursor-rules-java"],"synonyms":[],"warnings":[],"endpointUrl":"https://skills.sh/jabrena/cursor-rules-java/142-java-functional-programming","protocol":"skill","transport":"skills-sh","auth":{"type":"none","details":{"cli":"npx skills add jabrena/cursor-rules-java","source_repo":"https://github.com/jabrena/cursor-rules-java","install_from":"skills.sh"}},"qualityScore":"0.631","qualityRationale":"deterministic score 0.63 from registry signals: · indexed on github topic:agent-skills · 362 github stars · SKILL.md body (3,309 chars)","verified":false,"liveness":"unknown","lastLivenessCheck":null,"agentReviews":{"count":0,"score_avg":null,"cost_usd_avg":null,"success_rate":null,"latency_p50_ms":null,"narrative_summary":null,"summary_updated_at":null},"enrichmentModel":"deterministic:skill-github:v1","enrichmentVersion":1,"enrichedAt":"2026-04-26T12:53:35.528Z","embedding":null,"createdAt":"2026-04-18T22:02:03.326Z","updatedAt":"2026-04-26T12:53:35.528Z","lastSeenAt":"2026-04-26T12:53:35.528Z","tsv":"'/mvnw':222,260,353,424 '1':346 '14':143 '142':1 '17':135 '2':364 '21':129 '3':382 '395':72 '4':403 '461':147 '5':418 'adopt':381 'ambigu':293 'andthen':112 'api':30,93 'appli':11,49,177,185,228,268,271,301,336,404,432 'applic':121,181 'area':176 'ask':296,318 'assess':389 'base':179 'boundari':150,417 'build':422 'case':288,304 'chang':189,230,302 'clarifi':298 'class':131 'clean':261,265,425,429 'code':171,332,341,390 'collect':160 'collector':99 'collectors.tounmodifiablelist':162 'compat':368 'compil':193,195,205,211,223,226,233,243,249,347,354,357,362,372 'compos':113 'composit':37,111,402 'confirm':365 'constraint':183,279,440 'consum':83 'core':157,175 'cover':63 'curri':119 'custom':85 'detail':276,436 'domain':138 'edg':155,287,303 'effect':78,149,153,415 'effect-boundari':148 'ensur':190 'exampl':169,182,278,438 'exhaust':137 'express':28,58,88,141 'fail':196,234,363 'featur':217,255,367,378 'file':308 'filter':105 'filter/map/reduce':94 'flatmap':104 'free':75 'full':421 'function':4,12,24,25,36,41,44,50,74,79,81,110,117,187,284,334,337,343,350,377,385,399,401,405,410 'functional-program':384 'functionalinterfac':86 'gather':145 'get':109 'good/bad':170,277 'guidanc':324,437 'hierarchi':139 'higher':39,115 'higher-ord':38,114 'identifi':47,394 'idiomat':101 'immedi':198,236,360 'immut':19,57,67,159,397 'implement':408 'improv':56,269,330,407,433 'includ':17 'input':307 'instanceof':125 'interfac':26,80,133 'ispres':108 'java':3,16,43,54,128,134,142,216,254,366 'java-functional-program':2 'jep':71,146 'keep':413 'lambda':27,87 'list.of':161 'logic':158 'maintain':60 'mandatori':220 'map':103 'match':123 'maven':210,248,371 'maven-compiler-plugin':209,247,370 'memoiz':118 'method':90 'miss':312,316 'mvn':225,264,356,428 'need':9 'null':34 'object':20,68 'opportun':395 'option':32,100 'order':40,116 'orels':106 'organ':167 'parallel':96 'partial':120 'pattern':42,122,172,286 'pipelin':31,95 'plan':379 'plugin':212,250,373 'predic':82 'principl':14,52 'proceed':201,239,321 'program':5,13,45,51,188,285,335,338,344,386,406 'project':192,204,242,348 'pure':23,73,156,398 'question':299 'read':272,383,391 'recommend':178 'record':22,70 'refactor':339,351,411 'refer':91,165,274,387,434 'references/142-java-functional-programming.md':392,442,443 'report':313 'request':290 'requir':306 'rule':46 'run':221,259,352,423 'safeguard':281 'safeti':35,231 'scope':163,291 'seal':130 'see':441 'select':409 'separ':151 'setup':323 'side':77,152,414 'skill':66,329 'skill-142-java-functional-programming' 'source-jabrena' 'source/target':213,251,374 'stop':197,235,294,359 'stream':29,92,97,144 'success':206,244 'supplier':84 'support':214,252,375 'switch':127,140 'tool':310 'topic-agent-skills' 'topic-ai-skills' 'topic-claude' 'topic-claude-code' 'topic-claude-code-skills' 'topic-claude-code-subagents' 'topic-claude-skills' 'topic-cursor-agent' 'topic-cursor-ai' 'topic-cursor-skills' 'topic-cursorai' 'topic-github-copilot' 'tounmodifi':98 'usag':102 'use':6,219,257,327 'verifi':207,245,246,258,262,266,369,419,426,430 'whether':319 'workflow':345 'write':18","prices":[{"id":"3d601be4-9cd1-450c-8453-5b6dc6cc8235","listingId":"cee6ad6e-5d6b-4155-90c9-2e2e0638212f","amountUsd":"0","unit":"free","nativeCurrency":null,"nativeAmount":null,"chain":null,"payTo":null,"paymentMethod":"skill-free","isPrimary":true,"details":{"org":"jabrena","category":"cursor-rules-java","install_from":"skills.sh"},"createdAt":"2026-04-18T22:02:03.326Z"}],"sources":[{"listingId":"cee6ad6e-5d6b-4155-90c9-2e2e0638212f","source":"github","sourceId":"jabrena/cursor-rules-java/142-java-functional-programming","sourceUrl":"https://github.com/jabrena/cursor-rules-java/tree/main/skills/142-java-functional-programming","isPrimary":false,"firstSeenAt":"2026-04-18T22:02:03.326Z","lastSeenAt":"2026-04-26T12:53:35.528Z"}],"details":{"listingId":"cee6ad6e-5d6b-4155-90c9-2e2e0638212f","quickStartSnippet":null,"exampleRequest":null,"exampleResponse":null,"schema":null,"openapiUrl":null,"agentsTxtUrl":null,"citations":[],"useCases":[],"bestFor":[],"notFor":[],"kindDetails":{"org":"jabrena","slug":"142-java-functional-programming","github":{"repo":"jabrena/cursor-rules-java","stars":362,"topics":["agent-skills","ai-skills","claude","claude-code","claude-code-skills","claude-code-subagents","claude-skills","cursor-agent","cursor-ai","cursor-skills","cursorai","github-copilot","intellij-idea","java","prompting","system-prompts"],"license":"apache-2.0","html_url":"https://github.com/jabrena/cursor-rules-java","pushed_at":"2026-04-26T12:50:01Z","description":"A curated and opinionated collection of Skills and Agents to be used in modern SDLC workflows for Java Enterprise development with your favorite AI Agent harness.","skill_md_sha":"e0c033bdcc6508c3f57d8cf1602eb0775a04914f","skill_md_path":"skills/142-java-functional-programming/SKILL.md","default_branch":"main","skill_tree_url":"https://github.com/jabrena/cursor-rules-java/tree/main/skills/142-java-functional-programming"},"layout":"multi","source":"github","category":"cursor-rules-java","frontmatter":{"name":"142-java-functional-programming","license":"Apache-2.0","description":"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. Part of cursor-rules-java project"},"skills_sh_url":"https://skills.sh/jabrena/cursor-rules-java/142-java-functional-programming"},"updatedAt":"2026-04-26T12:53:35.528Z"}}