{"id":18088263,"url":"https://github.com/memoizr/retro-optional","last_synced_at":"2026-01-26T17:34:24.040Z","repository":{"id":89291118,"uuid":"45855545","full_name":"memoizr/retro-optional","owner":"memoizr","description":"A backport of Java8 optionals for Java7","archived":false,"fork":false,"pushed_at":"2017-06-23T11:32:18.000Z","size":124,"stargazers_count":16,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-29T03:55:20.947Z","etag":null,"topics":["backport","java","java8-optionals","monadic-optionals"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/memoizr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-11-09T17:46:32.000Z","updated_at":"2020-09-28T11:40:13.000Z","dependencies_parsed_at":null,"dependency_job_id":"b8b2d4d6-f661-4a76-9515-1ba61681c730","html_url":"https://github.com/memoizr/retro-optional","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/memoizr%2Fretro-optional","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/memoizr%2Fretro-optional/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/memoizr%2Fretro-optional/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/memoizr%2Fretro-optional/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/memoizr","download_url":"https://codeload.github.com/memoizr/retro-optional/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239652953,"owners_count":19675004,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["backport","java","java8-optionals","monadic-optionals"],"created_at":"2024-10-31T17:12:34.738Z","updated_at":"2025-12-02T22:30:14.117Z","avatar_url":"https://github.com/memoizr.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/memoizr/retro-optional.svg?branch=master)](https://travis-ci.org/memoizr/retro-optional)\n[![codecov](https://codecov.io/gh/memoizr/retro-optional/branch/master/graph/badge.svg)](https://codecov.io/gh/memoizr/retro-optional)\n[![](https://jitpack.io/v/memoizr/retro-optional.svg)](https://jitpack.io/#memoizr/retro-optional)\n[![GitHub license](https://img.shields.io/github/license/kotlintest/kotlintest.svg)](http://www.apache.org/licenses/LICENSE-2.0.html) \n## Retro-Optional\nA backport of Java8 monad optionals for Java7.\n\nExample:\nLet's say we have an instance of a class `A` which can be nullable, and we're interested in getting the\nresult of a chain of nested function calls, which eventually will result in a `boolean`. Every intermediate\nstep may fail and return a null. To get to the end result without optionals we'd have to do multiple\nnull checks:\n\n```java\nboolean result = a != null \u0026\u0026\n      a.getB() != null \u0026\u0026\n      a.getB().getC() != null \u0026\u0026\n      a.getB().getC().isD();\n```\nBut by converting everything to return monadic optionals, the syntax can be streamlined a bit:\n```java\nboolean result = a.flatMap(A::getB)\n      .flatMap(A::getC)\n      .filter(x -\u003e x.isD())\n      .isPresent();\n```\nFor more examples of how to use Java 8 optional types, you can refer to this excellent article:\nhttp://www.nurkiewicz.com/2013/08/optional-in-java-8-cheat-sheet.html\n\n## Get it\n```groovy\n repositories {\n        // ...\n        maven { url \"https://jitpack.io\" }\n  }\n```\n```groovy\n dependencies {\n        compile 'com.github.memoizr:retro-optional:0.2.0'\n  }\n```\n\nCopyright 2015 memoizr\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n    Unless required by applicable law or agreed to in writing, software\n    distributed under the License is distributed on an \"AS IS\" BASIS,\n    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n    implied.\n    See the License for the specific language governing permissions and\n    limitations under the License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmemoizr%2Fretro-optional","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmemoizr%2Fretro-optional","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmemoizr%2Fretro-optional/lists"}