{"id":15351129,"url":"https://github.com/realityforge/braincheck","last_synced_at":"2026-01-02T22:43:09.788Z","repository":{"id":57739960,"uuid":"104299782","full_name":"realityforge/braincheck","owner":"realityforge","description":null,"archived":false,"fork":false,"pushed_at":"2024-07-26T02:52:37.000Z","size":597,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-26T08:37:34.907Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://realityforge.org/braincheck","language":"Java","has_issues":false,"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/realityforge.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":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-09-21T04:00:19.000Z","updated_at":"2024-07-26T02:52:40.000Z","dependencies_parsed_at":"2024-01-18T07:49:48.467Z","dependency_job_id":"8e1b802e-a22e-4fb6-83f9-615d3eb38025","html_url":"https://github.com/realityforge/braincheck","commit_stats":null,"previous_names":[],"tags_count":32,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/realityforge%2Fbraincheck","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/realityforge%2Fbraincheck/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/realityforge%2Fbraincheck/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/realityforge%2Fbraincheck/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/realityforge","download_url":"https://codeload.github.com/realityforge/braincheck/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243806033,"owners_count":20350775,"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":[],"created_at":"2024-10-01T12:01:34.151Z","updated_at":"2026-01-02T22:43:09.775Z","avatar_url":"https://github.com/realityforge.png","language":"Java","readme":"# Braincheck\n\n[![Build Status](https://api.travis-ci.com/realityforge/braincheck.svg?branch=master)](http://travis-ci.com/realityforge/braincheck)\n[\u003cimg src=\"https://img.shields.io/maven-central/v/org.realityforge.braincheck/braincheck.svg?label=latest%20release\"/\u003e](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22org.realityforge.braincheck%22%20a%3A%22braincheck%22)\n![GWT3/J2CL compatible](https://img.shields.io/badge/GWT3/J2CL-compatible-brightgreen.svg)\n\nBraincheck is a very simple library that you can used to check invariants in code. It is designed that these invariant\nchecks can be compiled out in production environments either by the JIT or the GWT compiler. Braincheck also super-sources\n`Objects.requireNonNull(...)` to call `javaemul.internal.InternalPreconditions.checkNotNull(...)` so that these guards\ncan be stripped by configuring the compile-time property `jre.checks.checkLevel` to `DISABLED`.\n\n## Quick Start\n\nThe simplest way to use Braincheck is to;\n\n* Review the [javadocs](http://realityforge.org/braincheck/).\n\n* Add the BrainCheck dependencies into the build system. i.e.\n\n```xml\n\u003cdependency\u003e\n   \u003cgroupId\u003eorg.realityforge.braincheck\u003c/groupId\u003e\n   \u003cartifactId\u003ebraincheck\u003c/artifactId\u003e\n   \u003cversion\u003e1.32.0\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n* If the application is a GWT application, then inherit from `org.realityforge.braincheck.BrainCheck`\n  in your .gwt.xml for a production build or inherit `org.realityforge.braincheck.BrainCheckDev` in a\n  development build. You can also explicitly set the configuration properties to control which parts\n  of the application are optimized away during builds. See the configuration properties section below.\n\n* Add invariant checks to your code to verify various conditions.\n\n```java\nimport static org.realityforge.braincheck.Guards.*;\n\nclass MyClass\n{\n  public void myMethod(int i)\n  {\n    // Raise an exception if condition (first parameter) is not true\n    apiInvariant( () -\u003e i \u003e 0, () -\u003e \"You are using the api incorrectly!\" );\n\n    // Raise an exception if condition (first parameter) is not true\n    invariant( () -\u003e 1 == 1, () -\u003e \"Maths has broken down!\" );\n\n    // Raise an exception if invariant checks enabled\n    fail( () -\u003e \"You have reached a failing scenario in the application\" );\n  }\n}\n\n```\n\n* You can also modify the invariant configuration in tests by setting system property\n  `braincheck.environment` to `development` and interacting with the `BrainCheckTestUtil`\n  class. i.e.\n\n```java\nimport org.realityforge.braincheck.BrainCheckTestUtil;\n\nclass MyTest\n{\n  @Test\n  public void myTest()\n  {\n    BrainCheckTestUtil.setCheckApiInvariants( true );\n    //...\n  }\n}\n\n```\n\n## Configuration Properties\n\nThe following configuration properties can be used to configure BrainCheck. These are mainly used to optimize\nthe size of applications that statically compile code (i.e. GWT) when we want to minimize code size.\n\n* `braincheck.verbose_error_messages` which can be set to `true` or `false` and if `true`, then invariant exception\n  messages will use the supplied message, otherwise no message will be passed to exception.\n* `braincheck.check_invariants` which can be set to `true` or `false` and if `false`, calls to `Guards.invariant()`\n  and `Guards.fail()` are ignored.\n* `braincheck.check_api_invariants` which can be set to `true` or `false` and if `false` or if\n  `braincheck.check_invariants` is false then calls to `Guards.apiInvariant()` are ignored.\n* `braincheck.environment` which can be set to `development` or `production` and defaults to `production`. If\n  `production` then the default values for `braincheck.verbose_error_messages`, `braincheck.check_invariants`\n  and `braincheck.check_api_invariants` will be `false` otherwise they will default to be `true`.\n","funding_links":[],"categories":["Miscellaneous Library"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frealityforge%2Fbraincheck","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frealityforge%2Fbraincheck","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frealityforge%2Fbraincheck/lists"}