{"id":15383808,"url":"https://github.com/jamessimone/apex-collections","last_synced_at":"2026-02-18T07:31:34.261Z","repository":{"id":98193610,"uuid":"101400734","full_name":"jamessimone/apex-collections","owner":"jamessimone","description":"Turn that frown upside down by adding chainable collection filtering methods to Apex","archived":false,"fork":false,"pushed_at":"2018-01-31T11:50:19.000Z","size":16,"stargazers_count":18,"open_issues_count":0,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-27T22:43:28.768Z","etag":null,"topics":["apex","collections","salesforce","salesforce-developers"],"latest_commit_sha":null,"homepage":null,"language":"Apex","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/jamessimone.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}},"created_at":"2017-08-25T12:16:29.000Z","updated_at":"2025-01-04T04:32:26.000Z","dependencies_parsed_at":null,"dependency_job_id":"c70de373-4275-4c1b-a2c0-1d015eb3fac9","html_url":"https://github.com/jamessimone/apex-collections","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jamessimone/apex-collections","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamessimone%2Fapex-collections","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamessimone%2Fapex-collections/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamessimone%2Fapex-collections/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamessimone%2Fapex-collections/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jamessimone","download_url":"https://codeload.github.com/jamessimone/apex-collections/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamessimone%2Fapex-collections/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29572395,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-18T06:19:27.422Z","status":"ssl_error","status_checked_at":"2026-02-18T06:18:44.348Z","response_time":162,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6: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":["apex","collections","salesforce","salesforce-developers"],"created_at":"2024-10-01T14:39:42.534Z","updated_at":"2026-02-18T07:31:34.246Z","avatar_url":"https://github.com/jamessimone.png","language":"Apex","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Apex Collections - chaining support for filtering Apex collections.\n\n\u003ca href=\"https://githubsfdeploy.herokuapp.com\"\u003e\n  \u003cimg alt=\"Deploy to Salesforce\" src=\"https://raw.githubusercontent.com/afawcett/githubsfdeploy/master/src/main/webapp/resources/img/deploy.png\"\u003e\n\u003c/a\u003e\n\nSalesforce's Apex implementation of Java has no support for lambdas, which makes working with the equivalent of IEnumerable\u003cT\u003e collections tiresome. Repeated \"for(...) { method body }\" loops abound\nin Apex code.\n\nFilter is a static helper class that can be chained to filter lists / other collections to:\n1. Update existing SObject values with the help of a map with matching key value\n2. Remove existing elements from a collection based on field level comparisons to a given value\n3. Improve readability of code by drawing attention towards the intent of each iteration instead of the actual looping mechanic through collections.\n\n### Example usage\n\n\n    List\u003cSObject\u003e filteredList = Filter.the(List\u003cSObject\u003e myList)\n        .byField(Schema.SObjectField myField)\n        .to\n        .filteredList()\n\n    Filter.the(List\u003cSObject\u003e myList)\n        .whereField(Schema.SObjectField myField)\n        .equals(Object valueOfMyFieldForAnyMatchingElement)\n\n    Filter.the((Map\u003cId or String, SObject\u003e) contactMap)\n        .whereField(Schema.SObjectField myField)\n        .is(null)\n        .andReplaceFieldWithValueFrom(Schema.SObjectField fieldInBaseCollection, Map\u003cId or String, SObject\u003e relatedMap, Schema.SObjectField fieldInRelatedMapToTakeValueFrom);\n\n    Set\u003cSObject\u003e filteredSet = Filter.the(List\u003cSObject\u003e myList)\n        .whereField(Schema.SObjectField myField)\n        .isNot(null)\n        .gather\n        .also\n        .whereField(Schema.SObjectField anotherField)\n        .equals(Object valueThatWhereFieldShouldEqual)\n        .gatherTo\n        .filteredSet();\n\n* first example returns List\u003cSObject\u003e with any elements removed from the first collection. Depending on your use case, you may not care about the return value. If that's the case, you can drop the \".to.filteredList()\" part.\n\n* Maps require a cast to (Map\u003cId, SObject\u003e) or (Map\u003cString, SObject\u003e).  The second parameter in \"andReplaceFieldWithValueFrom\" is a map that needs to have a matching key value!  Useful if you are working with multiple maps at a time and need to update values in the first map with a field value from the second.\n\n* Some functions / property calls are optional.  \"also\" , and \"to\" are merely there to assist in the readability.  If your list comprehensions level is over 9000, you may of course abstain from such things.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjamessimone%2Fapex-collections","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjamessimone%2Fapex-collections","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjamessimone%2Fapex-collections/lists"}