{"id":48904639,"url":"https://github.com/JunggiKim/java-refined","last_synced_at":"2026-05-02T20:00:35.443Z","repository":{"id":344139348,"uuid":"1178486917","full_name":"JunggiKim/java-refined","owner":"JunggiKim","description":"Refinement and functional value types for Java 8+","archived":false,"fork":false,"pushed_at":"2026-03-13T10:01:02.000Z","size":294,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-13T19:45:52.015Z","etag":null,"topics":["functional-programming","java","java8","maven-central","non-empty","refinement-types","validation"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JunggiKim.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-03-11T04:17:26.000Z","updated_at":"2026-03-13T09:15:17.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/JunggiKim/java-refined","commit_stats":null,"previous_names":["junggikim/java-refined"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/JunggiKim/java-refined","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JunggiKim%2Fjava-refined","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JunggiKim%2Fjava-refined/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JunggiKim%2Fjava-refined/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JunggiKim%2Fjava-refined/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JunggiKim","download_url":"https://codeload.github.com/JunggiKim/java-refined/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JunggiKim%2Fjava-refined/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32547651,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-02T19:18:06.202Z","status":"ssl_error","status_checked_at":"2026-05-02T19:16:21.335Z","response_time":132,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["functional-programming","java","java8","maven-central","non-empty","refinement-types","validation"],"created_at":"2026-04-16T19:00:43.475Z","updated_at":"2026-05-02T20:00:35.437Z","avatar_url":"https://github.com/JunggiKim.png","language":"Java","funding_links":[],"categories":["Projects"],"sub_categories":["Utility"],"readme":"# Java Refined\n\n[![CI](https://github.com/JunggiKim/java-refined/actions/workflows/ci.yml/badge.svg)](https://github.com/JunggiKim/java-refined/actions/workflows/ci.yml)\n[![License](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![Maven Central](https://img.shields.io/maven-central/v/io.github.junggikim/java-refined)](https://central.sonatype.com/artifact/io.github.junggikim/java-refined)\n[![Coverage](https://img.shields.io/badge/coverage-100%25-brightgreen.svg)](https://github.com/JunggiKim/java-refined/actions)\n[![Mutation](https://img.shields.io/badge/mutation-95%25+-blue.svg)](https://github.com/JunggiKim/java-refined/actions)\n\nMove validation into the type system. Zero runtime dependencies. Java 8+.\n\n## Why\n\nValidated wrapper types are not a new idea — but existing JVM tools\nonly give you the **pattern**, not the types themselves.\n\n| Tool | What it provides | Pre-built types |\n|------|-----------------|----------------|\n| Jakarta Bean Validation | Annotations (`@NotNull`, `@Min`) — checked only when `validate()` is called | 0 |\n| VAVR | `Validation\u003cE,A\u003e` monad — great error accumulation, but the validated value is still just `Integer` | 0 |\n| Arrow-kt | Smart-constructor pattern via `Exact\u003cA,B\u003e` — ~10 lines of boilerplate per type | 0 |\n| Kotlin value class | Language feature — you write everything yourself, Kotlin-only | 0 |\n\njava-refined ships **123+ ready-to-use types**.\n`PositiveInt`, `NonBlankString`, `EmailString` — import and go.\nZero dependencies. Java 8+.\n\n## Before\n\n```java\npublic void createUser(String name, int age, List\u003cString\u003e roles) {\n    if (name == null || name.trim().isEmpty()) {\n        throw new IllegalArgumentException(\"name must not be blank\");\n    }\n    if (age \u003c= 0) {\n        throw new IllegalArgumentException(\"age must be positive\");\n    }\n    if (roles == null || roles.isEmpty()) {\n        throw new IllegalArgumentException(\"roles must not be empty\");\n    }\n    // business logic ...\n}\n```\n\n## After\n\n```java\npublic void createUser(NonBlankString name, PositiveInt age, NonEmptyList\u003cString\u003e roles) {\n    // no validation needed — the types guarantee it\n}\n```\n\nTypes replace scattered `if`-checks. Invalid data cannot even reach your method.\n\n## Quick Start\n\n```java\n// Trusted data — just unwrap\nPositiveInt confirmedAge = PositiveInt.unsafeOf(18);\n\n// Untrusted input — safe fallback\nPositiveInt safeAge = PositiveInt.ofOrElse(userInput, 1);\n```\n\n```java\n// Branch on success/failure\nEmailString.of(email).fold(\n    error -\u003e badRequest(error.message()),\n    valid -\u003e ok(register(valid))\n);\n```\n\n## Kotlin Support\n\nOptional module with Kotlin-idiomatic extensions:\n\n```kotlin\nimport io.github.junggikim.refined.kotlin.*\n\nval name = \"Ada\".toNonBlankStringOrThrow()\nval tags = listOf(\"java\", \"fp\").toNonEmptyListOrThrow()\n```\n\n```kotlin\n// Safe fallback\nval safeAge = PositiveInt.ofOrElse(input, 1)\n```\n\n```kotlin\n// Kotlin-idiomatic nullable\nval age = PositiveInt.of(input).getOrNull() ?: PositiveInt.unsafeOf(1)\n```\n\n```kotlin\n// Convert to kotlin.Result\nval result: Result\u003cPositiveInt\u003e = PositiveInt.of(input).toResult()\n```\n\n## API\n\nAll refined wrappers follow the same pattern:\n\n- `of(value)` — returns `Validation\u003cViolation, T\u003e`, never throws\n- `unsafeOf(value)` — throws `RefinementException` on invalid input\n- `ofOrElse(value, default)` — returns validated instance or falls back to `default`\n- `ofStream(stream)` — collection wrappers only\n\nCollection refined types implement JDK interfaces directly — `NonEmptyList\u003cT\u003e` is a `List\u003cT\u003e`, `NonEmptyMap\u003cK,V\u003e` is a `Map\u003cK,V\u003e`. No unwrapping needed.\n\n## For AI-Assisted Development\n\nMethod signatures are contracts that AI agents cannot ignore.\n\nWhen your API accepts `PositiveInt` instead of `int`, code generators\nand AI assistants are **forced** to provide validated values —\nno scattered `if`-checks to forget or duplicate.\n\n## Installation\n\n\u003e *\"I can just implement this myself. Why add a dependency?\"*\n\u003e\n\u003e Totally fair! Copy the source into your project — it's MIT licensed.\n\u003e But if it saved you some time... give me a ⭐ 🥺\n\nPublished to [Maven Central](https://central.sonatype.com/artifact/io.github.junggikim/java-refined). Kotlin/JVM users can optionally add `java-refined-kotlin` for extension functions (adds `kotlin-stdlib` dependency).\n\n### Gradle Kotlin DSL\n\n```kotlin\ndependencies {\n    implementation(\"io.github.junggikim:java-refined:1.1.0\")\n\n    // optional: Kotlin extensions\n    // implementation(\"io.github.junggikim:java-refined-kotlin:1.1.0\")\n}\n```\n\n### Maven\n\n```xml\n\u003cdependency\u003e\n  \u003cgroupId\u003eio.github.junggikim\u003c/groupId\u003e\n  \u003cartifactId\u003ejava-refined\u003c/artifactId\u003e\n  \u003cversion\u003e1.1.0\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n## Supported Types\n\n| Category | Examples | Count |\n| --- | --- | --- |\n| Numeric | `PositiveInt`, `NegativeLong`, `NonZeroDouble`, `ZeroToOneFloat` | 46 |\n| Character | `DigitChar`, `LetterChar`, `UpperCaseChar` | 7 |\n| String | `NonBlankString`, `EmailString`, `UuidString`, `Ipv4String`, `JwtString` | 48 |\n| Collection | `NonEmptyList`, `NonEmptySet`, `NonEmptyMap`, `NonEmptyDeque`, `NonEmptyNavigableMap`, ... | 10 |\n| Control | `Option`, `Either`, `Try`, `Ior`, `Validated` | 5 |\n| Predicates | `GreaterThan`, `LengthBetween`, `MatchesRegex`, `AllOf`, `ForAllElements` | 55+ |\n\nFull list: [docs/type-matrix.md](docs/type-matrix.md)\n\n## Docs\n\n- [Type Matrix](docs/type-matrix.md)\n- [Compatibility](docs/compatibility.md)\n- [Kotlin Support Policy](docs/kotlin-support-policy.md)\n\n## Contributing\n\n[CONTRIBUTING.md](CONTRIBUTING.md) · [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md) · [SECURITY.md](SECURITY.md)\n\n## License\n\nMIT. See [LICENSE](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FJunggiKim%2Fjava-refined","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FJunggiKim%2Fjava-refined","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FJunggiKim%2Fjava-refined/lists"}