-
Notifications
You must be signed in to change notification settings - Fork 14
Feat/add tuple #122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
codefriar
wants to merge
22
commits into
main
Choose a base branch
from
feat/AddTupple
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Feat/add tuple #122
Changes from 6 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
1be71cc
introducing Tuple
codefriar c00518b
Feat(Tuple): Introducing Tuple
codefriar 96372af
fix(Tuple.cls): Adding doc blocks
codefriar 03a26b7
refactor(Tuple): accepting CodeRabit review suggestions
codefriar 83a3a29
refactor(Tuple): accepting CodeRabit review suggestions
codefriar b62047d
fix(ci-pr.yml): formatting
codefriar 8207b77
Update ci-pr.yml
codefriar 940717f
build(npm): bump @cparra/apexdocs from 2.17.0 to 2.17.1 (#115)
dependabot[bot] 93e2031
build(npm): bump eslint from 8.50.0 to 8.51.0 (#116)
dependabot[bot] 805c0bb
build(npm): bump @cparra/apexdocs from 2.17.1 to 2.17.2 (#117)
dependabot[bot] dfed13f
build(npm): bump marked from 9.1.0 to 9.1.1 (#118)
dependabot[bot] b4a5956
build(npm): bump marked from 9.1.1 to 9.1.2 (#120)
dependabot[bot] fecbea5
build(npm): bump lint-staged from 14.0.1 to 15.0.1 (#119)
dependabot[bot] d19e20e
build(npm): bump @babel/traverse from 7.23.0 to 7.23.2 (#121)
dependabot[bot] 4cce47c
Update ci-pr.yml
codefriar ee3f6df
refactor(ci-pr.yml): fixing this branches' ci-pr yml
codefriar 9ff506b
Update project-scratch-def.json
codefriar 0efb55e
fix(project-scratch-def): removing pre-release
codefriar b8486d1
fix(project-scratch-def): removing pre-release
codefriar 56bec3a
fix(project-scratch-def): removing pre-release check from create scra…
codefriar e0115b6
rename directory, update exclusions
dschach b8a13cd
Merge branch 'main' into feat/AddTupple
codefriar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,162 @@ | ||
| `APIVERSION: 58` | ||
|
|
||
| `STATUS: ACTIVE` | ||
|
|
||
| Tuple represents a key-value pair. Kinda. Don't come at me math nerds. | ||
codefriar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| You may be asking why this exists, given the existence of Map. Unfortuately Map isn't available everywhere. | ||
| Notably, it's not available in Apex-defined Data Types used by Flow/Invocable actions. | ||
| Additionally, `Object` is not a valid data type in Apex-defined Data Types, so we can't use a list of objects | ||
| that have a string key, and Object value. This is the next best thing. A kind of polyfill for Map<String,Object> | ||
| for use in Apex-defined Data Types. | ||
| See also: https://help.salesforce.com/s/articleView?id=sf.flow_considerations_apex_data_type.htm&type=5 | ||
codefriar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Available primitive datatypes available for use in tuple: | ||
| Boolean, Integer, Long, Decimal, Double, Date, DateTime, and String. Single values and lists are supported for each data type. | ||
|
|
||
| ## Constructors | ||
|
|
||
| ### `public Tuple()` | ||
|
|
||
| `SUPPRESSWARNINGS` | ||
|
|
||
| In order to create a Tuple instance from within a flow, you need a no-arg constructor. | ||
|
|
||
| ### `public Tuple(String key, Object value)` | ||
|
|
||
| standard constructor accepting a key and value | ||
|
|
||
| #### Parameters | ||
|
|
||
| | Param | Description | | ||
| | ------- | ----------------------------------- | | ||
| | `key` | String the name of the Tuple's Key. | | ||
| | `value` | Object the Tuple's Value. | | ||
|
|
||
| --- | ||
|
|
||
| ## Fields | ||
|
|
||
| ### `public booleanValue` → `Boolean` | ||
|
|
||
| `AURAENABLED` | ||
| `INVOCABLEVARIABLE` | ||
|
|
||
| ### `public booleans` → `Boolean` | ||
|
|
||
codefriar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| `AURAENABLED` | ||
| `INVOCABLEVARIABLE` | ||
|
|
||
| ### `public dateTimeValue` → `Datetime` | ||
|
|
||
| `AURAENABLED` | ||
| `INVOCABLEVARIABLE` | ||
|
|
||
| ### `public dateValue` → `Date` | ||
|
|
||
| `AURAENABLED` | ||
| `INVOCABLEVARIABLE` | ||
|
|
||
| ### `public dates` → `Date` | ||
|
|
||
codefriar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| `AURAENABLED` | ||
| `INVOCABLEVARIABLE` | ||
|
|
||
| ### `public datetimes` → `Datetime` | ||
|
|
||
codefriar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| `AURAENABLED` | ||
| `INVOCABLEVARIABLE` | ||
|
|
||
| ### `public decimalValue` → `Decimal` | ||
|
|
||
| `AURAENABLED` | ||
| `INVOCABLEVARIABLE` | ||
|
|
||
| ### `public decimals` → `Decimal` | ||
|
|
||
dschach marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| `AURAENABLED` | ||
| `INVOCABLEVARIABLE` | ||
|
|
||
| ### `public doubleValue` → `Double` | ||
|
|
||
| `AURAENABLED` | ||
| `INVOCABLEVARIABLE` | ||
|
|
||
| ### `public doubles` → `Double` | ||
|
|
||
dschach marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| `AURAENABLED` | ||
| `INVOCABLEVARIABLE` | ||
|
|
||
| ### `public integerValue` → `Integer` | ||
|
|
||
| `AURAENABLED` | ||
| `INVOCABLEVARIABLE` | ||
|
|
||
| ### `public integers` → `Integer` | ||
|
|
||
codefriar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| `AURAENABLED` | ||
| `INVOCABLEVARIABLE` | ||
|
|
||
| ### `public key` → `String` | ||
|
|
||
| `AURAENABLED` | ||
| `INVOCABLEVARIABLE` | ||
|
|
||
| ### `public longValue` → `Long` | ||
|
|
||
| `AURAENABLED` | ||
| `INVOCABLEVARIABLE` | ||
|
|
||
| ### `public longs` → `Long` | ||
|
|
||
codefriar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| `AURAENABLED` | ||
| `INVOCABLEVARIABLE` | ||
|
|
||
| ### `public sobjectValue` → `SObject` | ||
|
|
||
| `AURAENABLED` | ||
| `INVOCABLEVARIABLE` | ||
|
|
||
| ### `public sobjects` → `SObject` | ||
|
|
||
codefriar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| `AURAENABLED` | ||
| `INVOCABLEVARIABLE` | ||
|
|
||
| ### `public stringValue` → `String` | ||
|
|
||
| `AURAENABLED` | ||
| `INVOCABLEVARIABLE` | ||
|
|
||
| ### `public strings` → `String` | ||
|
|
||
codefriar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| `AURAENABLED` | ||
| `INVOCABLEVARIABLE` | ||
|
|
||
| --- | ||
|
|
||
| ## Methods | ||
|
|
||
| ### `private void determineTypeAndSetCastedValue(Object value)` | ||
|
|
||
codefriar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| `SUPPRESSWARNINGS` | ||
|
|
||
| Method is responsible for determining the type of the value and setting the appropriate field. | ||
|
|
||
| #### Parameters | ||
|
|
||
| | Param | Description | | ||
| | ------- | ------------------------- | | ||
| | `value` | Object the Tuple's Value. | | ||
|
|
||
| --- | ||
|
|
||
| ## Classes | ||
|
|
||
| ### TupleException | ||
|
|
||
| A custom Exception type thrown when the incoming Object is not a recognized Apex-defined-type safe | ||
| type. | ||
codefriar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| **Inheritance** | ||
|
|
||
| TupleException | ||
|
|
||
| --- | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
152 changes: 152 additions & 0 deletions
152
force-app/main/default/classes/Data Structures/Tuple.cls
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,152 @@ | ||
| /** | ||
| * @description Tuple represents a key-value pair. Kinda. Don't come at me math nerds. | ||
| * | ||
| * You may be asking why this exists, given the existence of Map. Unfortuately Map isn't available everywhere. | ||
| * Notably, it's not available in Apex-defined Data Types used by Flow/Invocable actions. | ||
| * | ||
| * Additionally, `Object` is not a valid data type in Apex-defined Data Types, so we can't use a list of objects | ||
| * that have a string key, and Object value. This is the next best thing. A kind of polyfill for Map<String,Object> | ||
| * for use in Apex-defined Data Types. | ||
| * | ||
| * See also: https://help.salesforce.com/s/articleView?id=sf.flow_considerations_apex_data_type.htm&type=5 | ||
| * Available primitive datatypes available for use in tuple: | ||
| * Boolean, Integer, Long, Decimal, Double, Date, DateTime, and String. Single values and lists are supported for each data type. | ||
| */ | ||
| @SuppressWarnings('PMD.StdCyclomaticComplexity') | ||
| public with sharing class Tuple { | ||
| @AuraEnabled | ||
| @InvocableVariable | ||
| public String key; | ||
|
|
||
| @AuraEnabled | ||
| @InvocableVariable | ||
| public Boolean[] booleans; | ||
| @AuraEnabled | ||
| @InvocableVariable | ||
| public Boolean booleanValue; | ||
| @AuraEnabled | ||
| @InvocableVariable | ||
| public Date dateValue; | ||
| @AuraEnabled | ||
| @InvocableVariable | ||
| public Date[] dates; | ||
| @AuraEnabled | ||
| @InvocableVariable | ||
| public Datetime[] datetimes; | ||
| @AuraEnabled | ||
| @InvocableVariable | ||
| public Datetime dateTimeValue; | ||
| @AuraEnabled | ||
| @InvocableVariable | ||
| public Double doubleValue; | ||
| @AuraEnabled | ||
| @InvocableVariable | ||
| public Double[] doubles; | ||
| @AuraEnabled | ||
| @InvocableVariable | ||
| public Decimal decimalValue; | ||
| @AuraEnabled | ||
| @InvocableVariable | ||
| public Decimal[] decimals; | ||
| @AuraEnabled | ||
| @InvocableVariable | ||
| public Integer integerValue; | ||
| @AuraEnabled | ||
| @InvocableVariable | ||
| public Integer[] integers; | ||
| @AuraEnabled | ||
| @InvocableVariable | ||
| public Long longValue; | ||
| @AuraEnabled | ||
| @InvocableVariable | ||
| public Long[] longs; | ||
| @AuraEnabled | ||
| @InvocableVariable | ||
| public String stringValue; | ||
| @AuraEnabled | ||
| @InvocableVariable | ||
| public String[] strings; | ||
| @AuraEnabled | ||
| @InvocableVariable | ||
| public SObject sobjectValue; | ||
| @AuraEnabled | ||
| @InvocableVariable | ||
| public SObject[] sobjects; | ||
|
|
||
| /** | ||
| * @description In order to create a Tuple instance from within a flow, you need a no-arg constructor. | ||
| */ | ||
| @SuppressWarnings('PMD.EmptyStatementBlock') | ||
| public Tuple() { | ||
| } | ||
|
|
||
| /** | ||
| * @description standard constructor accepting a key and value | ||
| * @param key String the name of the Tuple's Key. | ||
| * @param value Object the Tuple's Value. | ||
| */ | ||
| public Tuple(String key, Object value) { | ||
codefriar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if (key == null) { | ||
| throw new TupleException('Key cannot be null'); | ||
| } | ||
| if (value == null) { | ||
| throw new TupleException('Value cannot be null'); | ||
| } | ||
| this.key = key; | ||
| determineTypeAndSetCastedValue(value); | ||
| } | ||
|
|
||
| /** | ||
| * @description Method is responsible for determining the type of the value and setting the appropriate field. | ||
| * @param value Object the Tuple's Value. | ||
| */ | ||
| @SuppressWarnings('PMD.CyclomaticComplexity, PMD.StdCyclomaticComplexity') | ||
| private void determineTypeAndSetCastedValue(Object value) { | ||
| if (value instanceof Boolean) { | ||
| this.booleanValue = (Boolean) value; | ||
| } else if (value instanceof List<Boolean>) { | ||
| this.booleans = (List<Boolean>) value; | ||
| } else if (value instanceof Datetime) { | ||
| this.dateTimeValue = (Datetime) value; | ||
| } else if (value instanceof List<Datetime>) { | ||
| this.datetimes = (List<Datetime>) value; | ||
| } else if (value instanceof Date) { | ||
| this.dateValue = (Date) value; | ||
| } else if (value instanceof List<Date>) { | ||
| this.dates = (List<Date>) value; | ||
| } else if (value instanceof Long) { | ||
| this.longValue = (Long) value; | ||
| } else if (value instanceof List<Long>) { | ||
| this.longs = (List<Long>) value; | ||
| } else if (value instanceof Integer) { | ||
| this.integerValue = (Integer) value; | ||
| } else if (value instanceof List<Integer>) { | ||
| this.integers = (List<Integer>) value; | ||
| } else if (value instanceof Decimal) { | ||
| this.decimalValue = (Decimal) value; | ||
| } else if (value instanceof List<Decimal>) { | ||
| this.decimals = (List<Decimal>) value; | ||
| } else if (value instanceof Double) { | ||
| this.doubleValue = (Double) value; | ||
| } else if (value instanceof List<Double>) { | ||
| this.doubles = (List<Double>) value; | ||
| } else if (value instanceof String) { | ||
| this.stringValue = (String) value; | ||
| } else if (value instanceof List<String>) { | ||
| this.strings = (List<String>) value; | ||
| } else if (value instanceof List<SObject>) { | ||
| this.sobjects = (List<SObject>) value; | ||
| } else if (value instanceof SObject) { | ||
| this.sobjectValue = (SObject) value; | ||
| } else { | ||
| throw new TupleException('Unsupported data type: ' + value); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * @description A custom Exception type thrown when the incoming Object is not a recognized Apex-defined-type safe | ||
| * type. | ||
| */ | ||
| public class TupleException extends Exception { | ||
codefriar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
codefriar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
codefriar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
5 changes: 5 additions & 0 deletions
5
force-app/main/default/classes/Data Structures/Tuple.cls-meta.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <ApexClass xmlns="http://soap.sforce.com/2006/04/metadata"> | ||
| <apiVersion>58.0</apiVersion> | ||
| <status>Active</status> | ||
| </ApexClass> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.