{"id":36601840,"url":"https://github.com/ufukhalis/when","last_synced_at":"2026-01-12T08:39:08.114Z","repository":{"id":57735088,"uuid":"245511944","full_name":"ufukhalis/when","owner":"ufukhalis","description":"Simple Matching","archived":false,"fork":false,"pushed_at":"2020-05-13T06:53:10.000Z","size":39,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-06T07:06:48.128Z","etag":null,"topics":["ifelse","pattern-matching","predicate-methods","switchcase"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ufukhalis.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-03-06T20:37:04.000Z","updated_at":"2021-12-01T00:00:55.000Z","dependencies_parsed_at":"2022-08-24T11:20:42.183Z","dependency_job_id":null,"html_url":"https://github.com/ufukhalis/when","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/ufukhalis/when","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ufukhalis%2Fwhen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ufukhalis%2Fwhen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ufukhalis%2Fwhen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ufukhalis%2Fwhen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ufukhalis","download_url":"https://codeload.github.com/ufukhalis/when/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ufukhalis%2Fwhen/sbom","scorecard":{"id":907261,"data":{"date":"2025-08-11","repo":{"name":"github.com/ufukhalis/when","commit":"60f87814f6cc5671bae45c5875f405262ab5b137"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Code-Review","score":0,"reason":"Found 0/24 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: Apache License 2.0: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-24T17:47:15.380Z","repository_id":57735088,"created_at":"2025-08-24T17:47:15.381Z","updated_at":"2025-08-24T17:47:15.381Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28337599,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-12T06:09:07.588Z","status":"ssl_error","status_checked_at":"2026-01-12T06:05:18.301Z","response_time":98,"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":["ifelse","pattern-matching","predicate-methods","switchcase"],"created_at":"2026-01-12T08:39:08.060Z","updated_at":"2026-01-12T08:39:08.105Z","avatar_url":"https://github.com/ufukhalis.png","language":"Java","readme":"[![Build Status](https://travis-ci.org/ufukhalis/when.svg?branch=master)](https://travis-ci.org/ufukhalis/when)\n[![Coverage Status](https://coveralls.io/repos/github/ufukhalis/when/badge.svg?branch=master)](https://coveralls.io/github/ufukhalis/when?branch=master)\n\nWHEN\n=======\n\n`WHEN` is a simple matching library which only needs Java 8+ version.\n\n\nHow to Use\n-------------\n\nFirstly, you should add latest `WHEN` dependency to your project.\n\n```$xslt\n\u003cdependency\u003e\n    \u003cgroupId\u003eio.github.ufukhalis\u003c/groupId\u003e\n    \u003cartifactId\u003ewhen\u003c/artifactId\u003e\n    \u003cversion\u003e0.0.6\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\nThen, we can easily build when conditions like below. `WHEN` won't work until you call the `toOptional`\nmethod.\n\n```$xslt\n\nOptional\u003cInteger\u003e result = When.of(integer)\n                .condition(i -\u003e i == 10, i -\u003e i + 1)\n                .condition(i -\u003e i == 20, i -\u003e i + 2)\n                .toOptional();\n\n```\n\nIf there is no match the optional value will be empty.\n\nYou can also pass `Optional`.\n\n```$xslt\n\nOptional\u003cInteger\u003e result = When.of(Optional.of(10))\n                .condition(i -\u003e i == 12, i -\u003e i + 1)\n                .condition(i -\u003e i == 11, i -\u003e i + 1)\n                .condition(i -\u003e i == 10, i -\u003e i + 1)\n                .toOptional();\n\n```\n\nAnd also you can use other methods to trigger pipeline such as `getOrElse` or `getOrElseGet`.\n\n```$xslt\n\nInteger result = When.of(integer)\n                .condition(i -\u003e i == 11, i -\u003e i + 1)\n                .condition(i -\u003e i == 12, i -\u003e i + 1)\n                .condition(i -\u003e i == 13, i -\u003e i + 1)\n                .getOrElseGet(() -\u003e 10);\n\n```\n\n```$xslt\n\nInteger result = When.of(integer)\n                .condition(i -\u003e i == 11, i -\u003e i + 1)\n                .condition(i -\u003e i == 12, i -\u003e i + 1)\n                .condition(i -\u003e i == 13, i -\u003e i + 1)\n                .getOrElse(10);\n\n```\n\n`When` project has also reactor `Mono` type support. \n\n```$xslt\n\nMono\u003cInteger\u003e result = When.of(Mono.just(10))\n                .condition(i -\u003e i == 10, i -\u003e 1)\n                .condition(i -\u003e i == 20, i -\u003e 2)\n                .execute();\n\n```\n\nImportant Note : If there are multiple match for `When`, it will return the last match. \nBut it won't execute previous matches.\n\nLicense\n------------\nAll code in this repository is licensed under the Apache License, Version 2.0. See [LICENCE](./LICENSE).","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fufukhalis%2Fwhen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fufukhalis%2Fwhen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fufukhalis%2Fwhen/lists"}