The Wayback Machine - https://web.archive.org/web/20230120001335/https://github.com/ipavlic/apex-fp
Skip to content

ipavlic/apex-fp

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.

I'm currently open for new opportunities: https://www.linkedin.com/in/ipavlic/

Apex FP

CI workflow codecov

Apex FP provides functional constructs for SObject collections!

Examples

Transform SObjects with a simple declarative API.

List<Opportunity> largeOpportunities = SObjectCollection.of(opportunities)
	.filter(Fn.Match
		.field(Opportunity.Amount).greaterThan(150000)
		.also(Opportunity.AccountId).equals(accountId))
	.asList();
List<Task> 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();
Map<Id, List<Account>> accountsByParentId = SObjectCollection.of(accounts).groupByIds(Account.ParentId);
Decimal averageOpportunityValue = SObjectCollection.of(opportunities).mapToDecimal(Opportunity.Amount).average();

Find more examples in the documentation.

Deploy to Salesforce

Deploy to Salesforce

Read the documentation

Apex FP documentation