Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ipavlic/apex-fp
Functional programming for Salesforce Apex
https://github.com/ipavlic/apex-fp
apex forcedotcom functional-programming salesforce salesforce-api salesforce-developers salesforcedx
Last synced: 20 days ago
JSON representation
Functional programming for Salesforce Apex
- Host: GitHub
- URL: https://github.com/ipavlic/apex-fp
- Owner: ipavlic
- License: mit
- Created: 2014-05-23T14:14:33.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2023-09-28T16:06:24.000Z (9 months ago)
- Last Synced: 2024-04-15T07:26:50.445Z (3 months ago)
- Topics: apex, forcedotcom, functional-programming, salesforce, salesforce-api, salesforce-developers, salesforcedx
- Language: Apex
- Homepage: https://www.apexfp.org
- Size: 1.37 MB
- Stars: 281
- Watchers: 30
- Forks: 73
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Lists
- awesome-stars - apex-fp
README
# Apex FP
![CI workflow](https://github.com/ipavlic/apex-fp/actions/workflows/ci.yml/badge.svg)
[![codecov](https://codecov.io/gh/ipavlic/apex-fp/branch/master/graph/badge.svg)](https://codecov.io/gh/ipavlic/apex-fp)Apex FP provides functional constructs for `SObject` collections!
## Examples
Transform `SObjects` with a simple declarative API.
```apex
List largeOpportunities = SObjectCollection.of(opportunities)
.filter(Fn.Match
.field(Opportunity.Amount).greaterThan(150000)
.also(Opportunity.AccountId).equals(accountId))
.asList();
``````apex
List prospectingTasks = SObjectCollection.of(Trigger.new)
.filter(Fn.Match.recordFields(new Opportunity(Stage = 'Prospecting')))
.mapAll(Fn.MapTo(Task.SObjectType)
.setField(Task.Subject, 'Follow up')
.mapField(Task.WhatId, Opportunity.Id))
.asList();
``````apex
Map> accountsByParentId = SObjectCollection.of(accounts).groupByIds(Account.ParentId);
``````apex
Decimal averageOpportunityValue = SObjectCollection.of(opportunities).mapToDecimal(Opportunity.Amount).average();
```
Find more examples in the documentation.## Deploy to Salesforce
## Read the documentation