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
| // First, let's declare a list of Strings, | |
| // using the previous String variables: | |
| String[] stringsToConcat = | |
| new String[]{singleSpaceString, nullString, notEmptyString}; | |
| // Now we can use a join method to concatenate the variables: | |
| String joinedText = String.join(stringsToConcat, ''); | |
| // This is the result: | |
| |DEBUG|concatenated joinedText: Samwise Gamgee is the real hero |
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
| /********************************* | |
| Imagine three strings: | |
| - one with a single space | |
| - one null | |
| - one not empty and not null | |
| *********************************/ | |
| String singleSpaceString = ' '; | |
| String nullString = null; | |
| String notEmptyString = 'Samwise Gamgee is the real hero'; |
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
| SObject[] sObjectCustomObject = new SObject[]{ new Custom_Object__c(Name = 'Custom Object Name') }; | |
| processCustomObject(sObjectCustomObject); | |
| private void processCustomObject(SObject[] customObjects) { | |
| for (Custom_Object__c obj : customObjects) System.debug(obj.Name); | |
| } |
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
| SObject[] sObjectAccounts = new SObject[]{ new Account(Name = 'Account Name') }; | |
| processAccounts(sObjectAccounts); | |
| private void processAccounts(SObject[] accounts) { | |
| for (Account acct : accounts) System.debug(acct.Name); | |
| } |
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
| SObject[] sObjectAccounts = new SObject[]{ new Account(Name = 'Account Name') }; | |
| processCustomObject(sObjectAccounts); | |
| // Using a list of sObject Accounts as a parameter (that expects a list of Custom Objects). | |
| private void processCustomObject(Custom_Object__c[] customObjects) { | |
| //for (Custom_Object__c customObj : customObjects) System.debug(customObj.Name); | |
| } |
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
| public class ParentComponentController { | |
| public String controllerValue; | |
| public void setControllerValue (String s) { | |
| controllerValue = s.toUpperCase(); | |
| } | |
| public String getControllerValue() { | |
| return controllerValue; |
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
| <apex:component controller="ParentComponentController"> | |
| <apex:attribute name="componentValue" description="Attribute on the component." | |
| type="String" required="required" assignTo="{!controllerValue}"/> | |
| <apex:pageBlock title="My Parent Custom Component"> | |
| <p> | |
| <code>componentValue</code> is "{!componentValue}" | |
| <br/> | |
| <code>controllerValue</code> is "{!controllerValue}" | |
| </p> | |
| </apex:pageBlock> |
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
| public class ChildComponentController { | |
| public String controllerValue; | |
| public void setControllerValue (String s) { | |
| controllerValue = s.toLowerCase(); | |
| } | |
| public String getControllerValue() { | |
| return controllerValue; |
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
| <apex:component controller="ChildComponentController"> | |
| <apex:attribute name="componentValue" description="Attribute on the component." | |
| type="String" required="required" assignTo="{!controllerValue}"/> | |
| <apex:pageBlock title="My Child Custom Component"> | |
| <p> | |
| <code>componentValue</code> is "{!componentValue}" | |
| <br/> | |
| <code>controllerValue</code> is "{!controllerValue}" | |
| </p> | |
| </apex:pageBlock> |
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
| @isTest | |
| private class MaintenanceRequestHelperTest { | |
| //Leverage a @testSetup method to reduce execution time and increase maintainability | |
| @testSetup | |
| static void allTheDataForThisTestClass() { | |
| // Principle #1: Create records from scratch! | |
| // Remember that Records created in a test setup method are rolled back at the end of test class execution. |
OlderNewer