{"id":35013529,"url":"https://github.com/beyond-the-cloud-dev/apex-consts","last_synced_at":"2026-03-15T22:16:30.200Z","repository":{"id":83915772,"uuid":"530402354","full_name":"beyond-the-cloud-dev/apex-consts","owner":"beyond-the-cloud-dev","description":"Framework to store Constants in Apex.","archived":false,"fork":false,"pushed_at":"2025-12-22T21:17:16.000Z","size":363,"stargazers_count":21,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-24T09:51:29.205Z","etag":null,"topics":["apex","apex-framework","salesforce"],"latest_commit_sha":null,"homepage":"https://beyondthecloud.dev/blog/constants-in-apex","language":"Apex","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/beyond-the-cloud-dev.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,"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":"2022-08-29T21:35:58.000Z","updated_at":"2025-12-22T21:17:19.000Z","dependencies_parsed_at":null,"dependency_job_id":"d1065372-9c48-47e2-9e94-14ec53b217d2","html_url":"https://github.com/beyond-the-cloud-dev/apex-consts","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/beyond-the-cloud-dev/apex-consts","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beyond-the-cloud-dev%2Fapex-consts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beyond-the-cloud-dev%2Fapex-consts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beyond-the-cloud-dev%2Fapex-consts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beyond-the-cloud-dev%2Fapex-consts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/beyond-the-cloud-dev","download_url":"https://codeload.github.com/beyond-the-cloud-dev/apex-consts/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beyond-the-cloud-dev%2Fapex-consts/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28072713,"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","status":"online","status_checked_at":"2025-12-27T02:00:05.897Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["apex","apex-framework","salesforce"],"created_at":"2025-12-27T05:07:12.525Z","updated_at":"2026-03-15T22:16:30.194Z","avatar_url":"https://github.com/beyond-the-cloud-dev.png","language":"Apex","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003ca href=\"https://apexfluently.beyondthecloud.dev/libraries/apex-consts.html\"\u003e\n    \u003cpicture\u003e\n      \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"./website/public/logo.png\"\u003e\n      \u003cimg alt=\"Apex Consts logo\" src=\"./website/public/logo.png\" height=\"98\"\u003e\n    \u003c/picture\u003e\n  \u003c/a\u003e\n  \u003ch1\u003eApex Consts\u003c/h1\u003e\n\n\u003ca href=\"https://beyondthecloud.dev\"\u003e\u003cimg alt=\"Beyond The Cloud logo\" src=\"https://img.shields.io/badge/MADE_BY_BEYOND_THE_CLOUD-555?style=for-the-badge\"\u003e\u003c/a\u003e\n\n\u003cimg alt=\"API version\" src=\"https://img.shields.io/badge/api-v65.0-blue?style=for-the-badge\"\u003e\n\u003ca href=\"https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/LICENSE\"\u003e\u003cimg alt=\"License\" src=\"https://img.shields.io/badge/license-mit-green?style=for-the-badge\"\u003e\u003c/a\u003e\n\u003cimg alt=\"GitHub Repo stars\" src=\"https://img.shields.io/github/stars/beyond-the-cloud-dev/apex-consts?style=for-the-badge\u0026logo=github\u0026color=blue\"\u003e\n\u003cimg alt=\"GitHub Release\" src=\"https://img.shields.io/github/v/release/beyond-the-cloud-dev/apex-consts?display_name=tag\u0026style=for-the-badge\u0026color=blue\"\u003e\n\u003c/div\u003e\n\n## Getting Started\n\nThe Constants Framework provides a structured approach for managing constants in the Apex.\n\nConsts Lib is part of [Apex Fluently](https://apexfluently.beyondthecloud.dev/), a suite of production-ready Salesforce libraries by Beyond the Cloud.\n\n## Example\n\n```java\nAccount acc = new Account(\n    Name = 'My Account',\n    Type = Consts.ACCOUNT.TYPE.PROSPECT,\n    Rating = Consts.ACCOUNT.RATING.HOT\n);\n```\n\n```java\nSystem.debug(Consts.ACCOUNT.TYPE.PROSPECT); //'Prospect'\nSystem.debug(Consts.ACCOUNT.RATING.HOT); //'Hit'\n\nSystem.debug(Consts.CONTACT.API_NAME); //'Contact'\nSystem.debug(Consts.CONTACT.LEAD_SOURCE.WEB); //'Web'\n\nSystem.debug(Consts.OPPORTUNITY.TYPE.EXISTING_CUSTOMER_DOWNGRADE); //'Existing Customer - Downgrade'\n```\n\n## How it works?\n\nThe framework employs the concept of singletons to create concrete classes.\nEach class is initialized once during the transaction, reducing heap size usage.\n\nGetters and setters are used to lazily initialize the classes.\nFor example, accessing `Consts.Account.TYPE.PROSPECT` will only create an instance of the `AccountConsts` class without creating `ContactConsts`.\n\nThe code architecture follows the Open/Closed and Single Responsibility Principle principles.\nThis design ensures the code is easily extensible, and each class is responsible for a specific set of constants.\n\n## How to use it?\n\n### Create a concrete consts class\n\n- Define an `INSTANCE` variable to hold the class instance (singleton).\n- Create inner classes to organize the constant values.\n\n```java\npublic class ContactConsts {\n    public static final ContactConsts INSTANCE = new ContactConsts();\n\n    public final String API_NAME = Contact.sObjectType.getDescribe().getName();\n\n    public final Status STATUS = new Status();\n\n    public class Status {\n        public final String IN_APPROVAL_PROCESS = 'In Approval Process';\n        public final String ACTIVATED = 'Activated';\n        public final String DRAFT = 'Draft';\n    }\n\n    private ContactConsts() {}\n}\n```\n\n### Add a concrete consts class to `Consts`\n\n```java\npublic class Consts {\n\n    public static final ContactConsts CONTACT {\n        get {\n            return ContactConsts.INSTANCE;\n        }\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbeyond-the-cloud-dev%2Fapex-consts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbeyond-the-cloud-dev%2Fapex-consts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbeyond-the-cloud-dev%2Fapex-consts/lists"}