{"id":20811540,"url":"https://github.com/nextbreakpoint/common","last_synced_at":"2025-12-26T07:20:36.588Z","repository":{"id":82319832,"uuid":"49142583","full_name":"nextbreakpoint/common","owner":"nextbreakpoint","description":"Common is a library which implements useful types for writing code in an elegant and concise style","archived":false,"fork":false,"pushed_at":"2024-06-30T18:43:10.000Z","size":157,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-18T14:47:25.567Z","etag":null,"topics":["fluent-api","functional-programming","java","java-library"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nextbreakpoint.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,"governance":null}},"created_at":"2016-01-06T15:15:31.000Z","updated_at":"2024-06-30T18:42:03.000Z","dependencies_parsed_at":"2023-07-10T18:15:37.653Z","dependency_job_id":null,"html_url":"https://github.com/nextbreakpoint/common","commit_stats":{"total_commits":83,"total_committers":5,"mean_commits":16.6,"dds":0.4337349397590361,"last_synced_commit":"bdb1d7ecc78e65b5898cc0669b93ed07dacc536f"},"previous_names":["nextbreakpoint/common"],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nextbreakpoint%2Fcommon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nextbreakpoint%2Fcommon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nextbreakpoint%2Fcommon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nextbreakpoint%2Fcommon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nextbreakpoint","download_url":"https://codeload.github.com/nextbreakpoint/common/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243158972,"owners_count":20245669,"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":["fluent-api","functional-programming","java","java-library"],"created_at":"2024-11-17T20:44:26.751Z","updated_at":"2025-12-26T07:20:36.560Z","avatar_url":"https://github.com/nextbreakpoint.png","language":"Java","readme":"# Common 3.0.3\n\nCommon is a library which implements useful types for writing code in an elegant and concise style.\n\n## License\n\nThis library is distributed under the terms of BSD 3-Clause License.\n\n    Copyright (c) 2016-2024, Andrea Medeghini\n    All rights reserved.\n\n    Redistribution and use in source and binary forms, with or without\n    modification, are permitted provided that the following conditions are met:\n\n    * Redistributions of source code must retain the above copyright notice, this\n      list of conditions and the following disclaimer.\n\n    * Redistributions in binary form must reproduce the above copyright notice,\n      this list of conditions and the following disclaimer in the documentation\n      and/or other materials provided with the distribution.\n\n    * Neither the name of NextBreakpoint Common library nor the names of its\n      contributors may be used to endorse or promote products derived from\n      this software without specific prior written permission.\n\n    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n    AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n    DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE\n    FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n    DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\n    SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\n    CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\n    OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n## Get binaries\n\nCommon library is available in Maven Central Repository and [GitHub](https://github.com/nextbreakpoint/common).\n\nIf you are using Maven, add the following dependency in your POM:\n\n    \u003cdependency\u003e\n        \u003cgroupId\u003ecom.nextbreakpoint\u003c/groupId\u003e\n        \u003cartifactId\u003ecom.nextbreakpoint.common\u003c/artifactId\u003e\n        \u003cversion\u003e3.0.3\u003c/version\u003e\n    \u003c/dependency\u003e\n\n## Documentation\n\nThe primary goal of this library is to provide the types for writing code in an elegant and concise style.\nAlso, the library aims to provide the building blocks for creating composable and reusable code.   \n\nFor instance, a typical fragment of code for handling exceptions in Java looks like:\n\n    try {\n        doSomething();\n    } catch (SomeException e) {\n        handleException(e);\n    }\n\nUsing Command and Either provided in the library we can rewrite the same code in a more elegant style:\n\n    Command.of(() -\u003e doSomething())\n        .execute()\n        .observe()\n        .onFailure(e -\u003e handleException(e))\n        .get();\n\n### Either class\n\nEither implements a fluent interface for composing operations and handling errors.\n\nEither can be created from a value or an exception:\n\n    Either.success(value)\n    Either.failure(exception)\n\nUse get(), orElse(), orElseGet() to get the value:\n\n    Either.success(value).get()\n    Either.success(value).orElse(otherValue)\n    Either.success(value).orElseGet(() -\u003e otherValue)\n\nUse orThrow() to rethrow the exception if present:\n\n    Either.failure(exception).orThrow()\n    Either.failure(exception).orThrow(e -\u003e new SomeException(e))\n\nUse or() to produce an alternative result:\n\n    // the composed either will ignore the failure and return the alternative value\n    Either.failure(exception).or(Either.success(value))\n\nUse map() and flatMap() to compose transformations:\n\n    Either.success(value).map(value -\u003e transform(value))\n    Either.success(value).flatMap(value -\u003e Either.success(transform(value)))\n\nUse exception() to get the exception if present:\n\n    // always null if either is success\n    Either.success(value).exception()\n    // always not null if either is failure\n    Either.failure(exception).exception()\n\nUse isSuccess() and isFailure() to check the status:\n\n    // always returns true if either is success\n    Either.success(value).isSuccess()\n    // always returns true if either is failure\n    Either.failure(exception).isFailure()\n\nUse observe() to observe the status:\n\n    Either.success(value)\n        .observe()\n        .onSuccess(value -\u003e handleValue(value))\n        .onFailure(error -\u003e handleError(error))\n        .get()\n\nUse optional() to create an Optional:\n\n    Either.success(value).optional()\n\nUse stream() to create a Stream:\n\n    Either.success(value).stream()\n\n### Command class\n\nCommand implements a fluent interface for composing operations and execute them as single command.\n\nCommand can be created from a value, an exception, an instance of Either, or an instance of Callable:\n\n    Command.value(value)\n    Command.error(exception)\n    Command.of(Either.success(value))\n    Command.of(() -\u003e doSomething())\n\nUse execute() to execute the composed operation:\n\n    // it will execute the command and return the result as instance of Either\n    Command.of(() -\u003e doSomething()).execute();\n\nUse map() and flatMap() to compose operations:\n\n    Command.of(() -\u003e doSomething()).map(value -\u003e processValue(value));\n    Command.of(() -\u003e doSomething()).flatMap(value -\u003e Command.of(processValue(value)));\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnextbreakpoint%2Fcommon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnextbreakpoint%2Fcommon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnextbreakpoint%2Fcommon/lists"}