{"id":37423156,"url":"https://github.com/ashr123/option","last_synced_at":"2026-01-16T06:09:13.100Z","repository":{"id":224087223,"uuid":"762367407","full_name":"ashr123/option","owner":"ashr123","description":"DOP version of Optional","archived":false,"fork":false,"pushed_at":"2025-09-22T06:54:03.000Z","size":94,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-22T08:43:16.063Z","etag":null,"topics":["java","java-21","maybe","maybe-monad","monad","nothing","option","option-monad","some"],"latest_commit_sha":null,"homepage":"","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/ashr123.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"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":"2024-02-23T16:24:36.000Z","updated_at":"2025-09-22T06:53:55.000Z","dependencies_parsed_at":"2024-09-16T06:42:43.553Z","dependency_job_id":"0588f46c-0d24-4101-9e29-1fcec4ad8dbc","html_url":"https://github.com/ashr123/option","commit_stats":null,"previous_names":["ashr123/option"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/ashr123/option","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ashr123%2Foption","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ashr123%2Foption/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ashr123%2Foption/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ashr123%2Foption/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ashr123","download_url":"https://codeload.github.com/ashr123/option/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ashr123%2Foption/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28477632,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T03:13:13.607Z","status":"ssl_error","status_checked_at":"2026-01-16T03:11:47.863Z","response_time":107,"last_error":"SSL_read: 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":["java","java-21","maybe","maybe-monad","monad","nothing","option","option-monad","some"],"created_at":"2026-01-16T06:09:12.306Z","updated_at":"2026-01-16T06:09:13.086Z","avatar_url":"https://github.com/ashr123.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Maven Central](https://img.shields.io/maven-central/v/io.github.ashr123/option.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22io.github.ashr123%22%20AND%20a:%22option%22)\n\n# Option\n\nSmall package that brings DOP of Optional to Java.\n\nGives you the possibility to write code as\n\n```java\nimport io.github.ashr123.option.None;\nimport io.github.ashr123.option.Option;\nimport io.github.ashr123.option.Some;\n\npublic record Pair\u003cL, R\u003e(L left, R right) {\n}\n\npublic static Integer intABSOption(Integer integer) {\n\treturn switch (Option.of(integer)) {\n\t\tcase Some(Integer i) when i \u003c 0 -\u003e -i;\n\t\tcase Some(Integer i) -\u003e i;\n\t\tcase None\u003cInteger\u003e ignored -\u003e null;\n\t};\n}\n\npublic static Integer intMax(Pair\u003cInteger, Integer\u003e pair) {\n\treturn switch (Option.of(pair)) {\n\t\tcase Some(Pair(Integer l, Integer r)) when l != null \u0026\u0026 r == null -\u003e l;\n\t\tcase Some(Pair(Integer l, Integer r)) when l == null \u0026\u0026 r != null -\u003e r;\n\t\tcase Some(Pair(Integer l, Integer r)) when l != null \u0026\u0026 r != null \u0026\u0026 l \u003e r -\u003e l;\n\t\tcase Some(Pair(Integer l, Integer r)) -\u003e r;\n\t\tcase None\u003cPair\u003cInteger, Integer\u003e\u003e ignored -\u003e null;\n\t};\n}\n```\n\n## Comparison against existing `Optional\u003cT\u003e`\n\n| `Optional` methods                                                     | `Option\u003cT\u003e opt` equivalent                                                                                             |\n|------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------|\n| `empty()`                                                              | `None.instance()`                                                                                                      |\n| `of(T value)`                                                          | `new Some\u003c\u003e(T value)`                                                                                                  |\n| `ofNullable(T value)`                                                  | \u003cul\u003e\u003cli\u003e`of(T value)`\u003c/li\u003e\u003cli\u003e`of(Optional\u003cT\u003e value)`\u003c/li\u003e\u003c/ul\u003e                                                        |\n| `get()`                                                                | \u003cul\u003e\u003cli\u003eswitch-case\u003c/li\u003e\u003cli\u003e`if (opt instanceof Some(T value)) ...`\u003c/li\u003e\u003c/ul\u003e                                          |\n| `isPresent()`                                                          | `if (opt instanceof Some\u003c?\u003e) ...`                                                                                      |\n| `isEmpty()`                                                            | `if (opt instanceof None\u003c?\u003e) ...`                                                                                      |\n| `ifPresent(Consumer\u003c? super T\u003e action)`                                | \u003cul\u003e\u003cli\u003eswitch-case\u003c/li\u003e\u003cli\u003e`if (opt instanceof Some(T value)) value ...`\u003c/li\u003e\u003c/ul\u003e                                    |\n| `ifPresentOrElse(Consumer\u003c? super T\u003e action, Runnable emptyAction)`    | switch-case                                                                                                            |\n| `filter(Predicate\u003c? super T\u003e predicate)`                               | `if (opt instanceof Some(T value) \u0026\u0026 value ...)`                                                                       |\n| `map(Function\u003c? super T, ? extends U\u003e mapper)`                         | \u003cul\u003e\u003cli\u003e`if (opt instanceof Some(T value)) value ...`\u003c/li\u003e\u003cli\u003e`map(Function\u003c? super T, ? extends U\u003e mapper)`\u003c/li\u003e\u003c/ul\u003e |\n| `flatMap(Function\u003c? super T, ? extends Optional\u003c? extends U\u003e\u003e mapper)` | `flatMap(Function\u003c? super T, ? extends Option\u003c? extends U\u003e\u003e mapper)`                                                   |\n| `or(Supplier\u003c? extends Optional\u003c? extends T\u003e\u003e supplier)`               | switch-case                                                                                                            |\n| `stream()`                                                             | `stream()`                                                                                                             |\n| `orElse(T other)`                                                      | switch-case                                                                                                            |\n| `orElseGet(Supplier\u003c? extends T\u003e supplier)`                            | switch-case                                                                                                            |\n| `orElseThrow()`                                                        | switch-case                                                                                                            |\n| `orElseThrow(Supplier\u003c? extends X\u003e exceptionSupplier)`                 | switch-case                                                                                                            |\n\nRequires JRE 21 or above.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fashr123%2Foption","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fashr123%2Foption","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fashr123%2Foption/lists"}