-
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
base: main
Are you sure you want to change the base?
Feat/add tuple #122
Conversation
Signed-off-by: kpoorman <kjp@codefriar.com>
A generic Apex Defined Type for use in flows. Contains primitive @AuraEnabled, @invocableVariable variables of every available type, as well as sObject and list<sObject> and logic to auto cast the incoming Object value to the correct primitive type. Signed-off-by: kpoorman <kjp@codefriar.com>
WalkthroughThis pull request introduces a new Changes
Uplevel your code reviews with CodeRabbit ProCodeRabbit ProIf you like this project, please support us by purchasing the Pro version. The Pro version has advanced context, superior noise reduction and several proprietary improvements compared to the open source version. Moreover, CodeRabbit Pro is free for open source projects. |
|
This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Files selected (4)
- docs/Tuple.md (1)
- docs/home.md (1)
- force-app/main/default/classes/Data Structures/Tuple.cls (1)
- force-app/main/default/classes/Data Structures/Tuple.cls-meta.xml (1)
Files skipped from review due to trivial changes (2)
- docs/home.md
- force-app/main/default/classes/Data Structures/Tuple.cls-meta.xml
Review comments generated (18)
- Review: 18
- LGTM: 0
Tips
Chat with
CodeRabbit Bot (@coderabbitai)
- Reply on review comments left by this bot to ask follow-up questions. A review comment is a comment on a diff or a file.
- Invite the bot into a review comment chain by tagging
@coderabbitaiin a reply.
Code suggestions
- The bot may make code suggestions, but please review them carefully before committing since the line number ranges may be misaligned.
- You can edit the comment made by the bot and manually tweak the suggestion if it is slightly off.
Pausing incremental reviews
- Add
@coderabbitai: ignoreanywhere in the PR description to pause further reviews from the bot.
Signed-off-by: kpoorman <kjp@codefriar.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Files selected (2)
- docs/Tuple.md (1)
- force-app/main/default/classes/Data Structures/Tuple.cls (1)
Files skipped from review due to trivial changes (1)
- docs/Tuple.md
Review comments generated (1)
- Review: 1
- LGTM: 0
Tips
Chat with
CodeRabbit Bot (@coderabbitai)
- Reply on review comments left by this bot to ask follow-up questions. A review comment is a comment on a diff or a file.
- Invite the bot into a review comment chain by tagging
@coderabbitaiin a reply.
Code suggestions
- The bot may make code suggestions, but please review them carefully before committing since the line number ranges may be misaligned.
- You can edit the comment made by the bot and manually tweak the suggestion if it is slightly off.
Pausing incremental reviews
- Add
@coderabbitai: ignoreanywhere in the PR description to pause further reviews from the bot.
Signed-off-by: kpoorman <kjp@codefriar.com>
Signed-off-by: kpoorman <kjp@codefriar.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Files selected (2)
- docs/Tuple.md (1)
- force-app/main/default/classes/Data Structures/Tuple.cls (1)
Review comments generated (12)
- Review: 12
- LGTM: 0
Tips
Chat with
CodeRabbit Bot (@coderabbitai)
- Reply on review comments left by this bot to ask follow-up questions. A review comment is a comment on a diff or a file.
- Invite the bot into a review comment chain by tagging
@coderabbitaiin a reply.
Code suggestions
- The bot may make code suggestions, but please review them carefully before committing since the line number ranges may be misaligned.
- You can edit the comment made by the bot and manually tweak the suggestion if it is slightly off.
Pausing incremental reviews
- Add
@coderabbitai: ignoreanywhere in the PR description to pause further reviews from the bot.
Removed the pre-release option Signed-off-by: kpoorman <kjp@codefriar.com>
dschach
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fascinated by this class. Seems you've accounted for every data type.
I added a comment for List.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Files selected (1)
- .github/workflows/ci-pr.yml (2)
Files skipped from review due to trivial changes (1)
- .github/workflows/ci-pr.yml
Review comments generated (0)
- Review: 0
- LGTM: 0
Tips
Chat with
CodeRabbit Bot (@coderabbitai)
- Reply on review comments left by this bot to ask follow-up questions. A review comment is a comment on a diff or a file.
- Invite the bot into a review comment chain by tagging
@coderabbitaiin a reply.
Code suggestions
- The bot may make code suggestions, but please review them carefully before committing since the line number ranges may be misaligned.
- You can edit the comment made by the bot and manually tweak the suggestion if it is slightly off.
Pausing incremental reviews
- Add
@coderabbitai: ignoreanywhere in the PR description to pause further reviews from the bot.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Files selected (5)
- .github/workflows/ci-pr.yml (2)
- docs/Tuple.md (1)
- docs/home.md (1)
- force-app/main/default/classes/Data Structures/Tuple.cls (1)
- force-app/main/default/classes/Data Structures/Tuple.cls-meta.xml (1)
Files skipped from review due to trivial changes (4)
- docs/Tuple.md
- docs/home.md
- force-app/main/default/classes/Data Structures/Tuple.cls
- force-app/main/default/classes/Data Structures/Tuple.cls-meta.xml
Review comments generated (2)
- Review: 2
- LGTM: 0
Tips
Chat with
CodeRabbit Bot (@coderabbitai)
- Reply on review comments left by this bot to ask follow-up questions. A review comment is a comment on a diff or a file.
- Invite the bot into a review comment chain by tagging
@coderabbitaiin a reply.
Code suggestions
- The bot may make code suggestions, but please review them carefully before committing since the line number ranges may be misaligned.
- You can edit the comment made by the bot and manually tweak the suggestion if it is slightly off.
Pausing incremental reviews
- Add
@coderabbitai: ignoreanywhere in the PR description to pause further reviews from the bot.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Files selected (50)
- .github/workflows/ci-pr.yml (1)
- docs/BulkCallable.md (2)
- docs/CanTheUser.md (24)
- docs/CanTheUserTests.md (1)
- docs/CustomInvocable.md (5)
- docs/ExampleQueueableProcessSteps.md (1)
- docs/FF.md (3)
- docs/FailsafeExceptionHandler.md (1)
- docs/FeatureFlag.md (6)
- docs/FeatureFlagCommonTests.md (4)
- docs/FeatureFlagDataProvider.md (5)
- docs/HttpCalloutMockFactory.md (2)
- docs/IdFactory.md (6)
- docs/Log.md (1)
- docs/LogMessage.md (1)
- docs/LogTriggerHandler.md (3)
- docs/MetadataTriggerFramework.md (3)
- docs/MetadataTriggerQueryService.md (3)
- docs/MethodSignature.md (8)
- docs/MockedMethod.md (16)
- docs/OrgShape.md (5)
- docs/Ouroboros.md (2)
- docs/OuroborosFinalizer.md (1)
- docs/OuroborosTests.md (1)
- docs/Polyfills.md (10)
- docs/Query.md (1)
- docs/QueueableProcess.md (3)
- docs/QueueableProcessDataProvider.md (1)
- docs/QueueableProcessTests.md (1)
- docs/QuiddityGuard.md (2)
- docs/RestClient.md (1)
- docs/RestClientLib.md (13)
- docs/RestLib.md (1)
- docs/RestLibApiCall.md (1)
- docs/SOQL.md (1)
- docs/SOQLAgregate.md (1)
- docs/SOSL.md (1)
- docs/Safely.md (12)
- docs/SampleHandler.md (3)
- docs/Stub.md (9)
- docs/StubUtilities.md (2)
- docs/TestFactory.md (16)
- docs/TriggerContext.md (1)
- docs/TriggerFramework.md (3)
- docs/TriggerFrameworkLoopCount.md (1)
- docs/UFInvocable.md (7)
- docs/ULID.md (3)
- docs/UniversalBulkInvocable.md (2)
- docs/UniversalFlowInputOutput.md (1)
- docs/UniversalInvocable.md (2)
Files not summarized due to errors (1)
- docs/CanTheUser.md (diff tokens exceeds limit)
Files not reviewed due to errors (16)
- docs/FeatureFlagCommonTests.md (no response)
- docs/CanTheUser.md (no response)
- docs/FeatureFlagDataProvider.md (no response)
- docs/LogTriggerHandler.md (no response)
- docs/MetadataTriggerFramework.md (no response)
- docs/MethodSignature.md (no response)
- docs/OrgShape.md (no response)
- docs/MockedMethod.md (no response)
- docs/Ouroboros.md (no response)
- docs/QuiddityGuard.md (no response)
- docs/SOQL.md (no response)
- docs/Safely.md (no response)
- docs/Stub.md (no response)
- docs/TestFactory.md (no response)
- docs/UniversalBulkInvocable.md (no response)
- docs/UniversalFlowInputOutput.md (no response)
Files skipped from review due to trivial changes (28)
- .github/workflows/ci-pr.yml
- docs/CanTheUserTests.md
- docs/ExampleQueueableProcessSteps.md
- docs/FF.md
- docs/FailsafeExceptionHandler.md
- docs/FeatureFlag.md
- docs/IdFactory.md
- docs/Log.md
- docs/LogMessage.md
- docs/MetadataTriggerQueryService.md
- docs/OuroborosFinalizer.md
- docs/OuroborosTests.md
- docs/Polyfills.md
- docs/Query.md
- docs/QueueableProcess.md
- docs/QueueableProcessTests.md
- docs/RestClient.md
- docs/RestClientLib.md
- docs/RestLib.md
- docs/RestLibApiCall.md
- docs/SOQLAgregate.md
- docs/SampleHandler.md
- docs/StubUtilities.md
- docs/TriggerContext.md
- docs/TriggerFramework.md
- docs/TriggerFrameworkLoopCount.md
- docs/UFInvocable.md
- docs/ULID.md
Review comments generated (16)
- Review: 6
- LGTM: 10
Tips
Chat with
CodeRabbit Bot (@coderabbitai)
- Reply on review comments left by this bot to ask follow-up questions. A review comment is a comment on a diff or a file.
- Invite the bot into a review comment chain by tagging
@coderabbitaiin a reply.
Code suggestions
- The bot may make code suggestions, but please review them carefully before committing since the line number ranges may be misaligned.
- You can edit the comment made by the bot and manually tweak the suggestion if it is slightly off.
Pausing incremental reviews
- Add
@coderabbitai: ignoreanywhere in the PR description to pause further reviews from the bot.
Bumps [@cparra/apexdocs](https://github.com/cesarParra/apexdocs) from 2.17.0 to 2.17.1. - [Release notes](https://github.com/cesarParra/apexdocs/releases) - [Commits](cesarParra/apexdocs@v2.17.0...v2.17.1) --- updated-dependencies: - dependency-name: "@cparra/apexdocs" dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [eslint](https://github.com/eslint/eslint) from 8.50.0 to 8.51.0. - [Release notes](https://github.com/eslint/eslint/releases) - [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md) - [Commits](eslint/eslint@v8.50.0...v8.51.0) --- updated-dependencies: - dependency-name: eslint dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [@cparra/apexdocs](https://github.com/cesarParra/apexdocs) from 2.17.1 to 2.17.2. - [Release notes](https://github.com/cesarParra/apexdocs/releases) - [Commits](cesarParra/apexdocs@v2.17.1...v2.17.2) --- updated-dependencies: - dependency-name: "@cparra/apexdocs" dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [marked](https://github.com/markedjs/marked) from 9.1.0 to 9.1.1. - [Release notes](https://github.com/markedjs/marked/releases) - [Changelog](https://github.com/markedjs/marked/blob/master/.releaserc.json) - [Commits](markedjs/marked@v9.1.0...v9.1.1) --- updated-dependencies: - dependency-name: marked dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [marked](https://github.com/markedjs/marked) from 9.1.1 to 9.1.2. - [Release notes](https://github.com/markedjs/marked/releases) - [Changelog](https://github.com/markedjs/marked/blob/master/.releaserc.json) - [Commits](markedjs/marked@v9.1.1...v9.1.2) --- updated-dependencies: - dependency-name: marked dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [lint-staged](https://github.com/okonet/lint-staged) from 14.0.1 to 15.0.1. - [Release notes](https://github.com/okonet/lint-staged/releases) - [Changelog](https://github.com/lint-staged/lint-staged/blob/master/CHANGELOG.md) - [Commits](lint-staged/lint-staged@v14.0.1...v15.0.1) --- updated-dependencies: - dependency-name: lint-staged dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [@babel/traverse](https://github.com/babel/babel/tree/HEAD/packages/babel-traverse) from 7.23.0 to 7.23.2. - [Release notes](https://github.com/babel/babel/releases) - [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md) - [Commits](https://github.com/babel/babel/commits/v7.23.2/packages/babel-traverse) --- updated-dependencies: - dependency-name: "@babel/traverse" dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Signed-off-by: kpoorman <kjp@codefriar.com>
Signed-off-by: kpoorman <kjp@codefriar.com>
599365e to
0efb55e
Compare
Signed-off-by: kpoorman <kjp@codefriar.com>
…tch org Signed-off-by: kpoorman <kjp@codefriar.com>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #122 +/- ##
=======================================
Coverage 95.00% 95.00%
=======================================
Files 32 32
Lines 2002 2002
=======================================
Hits 1902 1902
Misses 100 100
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Files selected (5)
- .github/workflows/ci-pr.yml (1)
- .gitignore (1)
- force-app/main/default/classes/dataStructures/Tuple.cls (1)
- force-app/main/default/classes/dataStructures/Tuple.cls-meta.xml (1)
- pmd/ruleset.xml (1)
Files ignored due to filter (1)
- config/project-scratch-def.json
Files skipped from review due to trivial changes (4)
- .github/workflows/ci-pr.yml
- .gitignore
- force-app/main/default/classes/dataStructures/Tuple.cls-meta.xml
- pmd/ruleset.xml
Review comments generated (1)
- Review: 1
- LGTM: 0
Tips
Chat with
CodeRabbit Bot (@coderabbitai)
- Reply on review comments left by this bot to ask follow-up questions. A review comment is a comment on a diff or a file.
- Invite the bot into a review comment chain by tagging
@coderabbitaiin a reply.
Code suggestions
- The bot may make code suggestions, but please review them carefully before committing since the line number ranges may be misaligned.
- You can edit the comment made by the bot and manually tweak the suggestion if it is slightly off.
Pausing incremental reviews
- Add
@coderabbitai: ignoreanywhere in the PR description to pause further reviews from the bot.
| /** | ||
| * @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) { | ||
| 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 { | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Tuple class seems to be well implemented. It provides a way to store different types of data in a single object, which can be useful in certain scenarios where the type of data is not known beforehand or can vary. The use of AuraEnabled and InvocableVariable annotations makes this class usable in Salesforce's Lightning Web Components and Flows respectively.
However, there are some potential improvements that could be made:
-
Error Handling: In the constructor
public Tuple(String key, Object value), you're throwing exceptions if either the key or value is null. While it's good to validate inputs, consider if this is the best approach for your use case. If null values are expected or acceptable in some scenarios, this could lead to unnecessary exceptions being thrown. -
Maintainability: The
determineTypeAndSetCastedValue(Object value)method has a high cyclomatic complexity due to the many conditional branches. This could make the code harder to maintain and test. Consider refactoring this into smaller methods or using a design pattern such as the Strategy pattern to handle different types. -
Performance: Each time a new
Tupleobject is created, thedetermineTypeAndSetCastedValue(Object value)method runs through a series ofifstatements until it finds the correct type. This could potentially impact performance if a large number ofTupleobjects are being created. Consider optimizing this logic. -
Security: The
Tupleclass includes fields for storingSObjectandList<SObject>types. Be aware that exposing SObjects directly can potentially expose sensitive data or allow for DML operations that bypass the usual security checks. Ensure that any usage of these fields respects the user's permissions and sharing rules. -
Consistency: The class uses both singular and plural field names (e.g.,
booleanValueandbooleans). This could potentially cause confusion. Consider adopting a consistent naming convention.
Here's an example of how you might refactor the determineTypeAndSetCastedValue(Object value) method to reduce its complexity:
private void determineTypeAndSetCastedValue(Object value) {
if (value instanceof Boolean) {
setBooleanValue(value);
} else if (value instanceof List<Boolean>) {
setBooleansValue(value);
} else if (value instanceof Datetime) {
setDatetimeValue(value);
} // ... continue for each type
}
private void setBooleanValue(Object value) {
this.booleanValue = (Boolean) value;
}
private void setBooleansValue(Object value) {
this.booleans = (List<Boolean>) value;
}
private void setDatetimeValue(Object value) {
this.dateTimeValue = (Datetime) value;
}
// ... continue for each typeThis approach breaks down the large method into smaller, more manageable methods, each responsible for setting a specific type of value. It also makes it easier to add or remove support for types in the future.
Summary by CodeRabbit
Tupleclass to provide key-value pair functionality similar toMap, enhancing support for various primitive data types..gitignoreand security rules inpmd/ruleset.xmlfor better repository management.