forked from apex-enterprise-patterns/fflib-apex-common
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added ability to pass in literals to fflib_Criteria
Started work on Date Literals for use with fflib_Criteria
- Loading branch information
1 parent
234dc61
commit 6907297
Showing
3 changed files
with
176 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
160 changes: 160 additions & 0 deletions
160
framework/default/ortoo-core/default/classes/fflib-extension/ortoo_DateLiterals.cls
This file contains 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,160 @@ | ||
/** | ||
* Class that provides a list of inner classes that can be used as targets for comparisons in ortoo_Criteria. | ||
* | ||
* Specifically, the classes represent the different Date Literals that SOQL supports | ||
* | ||
* @group fflib Extension | ||
*/ | ||
public inherited sharing class ortoo_DateLiterals | ||
{ | ||
// TODO: consider 'compare' - how do we do that? | ||
private interface Literal extends fflib_Criteria.Literal {} | ||
|
||
public class Today implements Literal | ||
{ | ||
public String toLiteral() | ||
{ | ||
return 'TODAY'; | ||
} | ||
} | ||
|
||
public class Yesterday implements Literal | ||
{ | ||
public String toLiteral() | ||
{ | ||
return 'YESTERDAY'; | ||
} | ||
} | ||
|
||
public class LastWeek implements Literal | ||
{ | ||
public String toLiteral() | ||
{ | ||
return 'LAST_WEEK'; | ||
} | ||
} | ||
|
||
public class ThisWeek implements Literal | ||
{ | ||
public String toLiteral() | ||
{ | ||
return 'THIS_WEEK'; | ||
} | ||
} | ||
|
||
public class NextWeek implements Literal | ||
{ | ||
public String toLiteral() | ||
{ | ||
return 'NEXT_WEEK'; | ||
} | ||
} | ||
|
||
public class LastMonth implements Literal | ||
{ | ||
public String toLiteral() | ||
{ | ||
return 'LAST_MONTH'; | ||
} | ||
} | ||
|
||
public class ThisMonth implements Literal | ||
{ | ||
public String toLiteral() | ||
{ | ||
return 'THIS_MONTH'; | ||
} | ||
} | ||
|
||
public class NextMonth implements Literal | ||
{ | ||
public String toLiteral() | ||
{ | ||
return 'NEXT_MONTH'; | ||
} | ||
} | ||
|
||
public class Last90Days implements Literal | ||
{ | ||
public String toLiteral() | ||
{ | ||
return 'LAST_90_DAYS'; | ||
} | ||
} | ||
|
||
public class Next90Days implements Literal | ||
{ | ||
public String toLiteral() | ||
{ | ||
return 'NEXT_90_DAYS'; | ||
} | ||
} | ||
|
||
public class LastNDays extends NumericallyQualifiedLiteral | ||
{ | ||
public LastNDays( Integer numberOfThings ) | ||
{ | ||
super( numberOfThings, 'LAST_N_DAYS' ); | ||
} | ||
} | ||
|
||
public class NextNDays extends NumericallyQualifiedLiteral | ||
{ | ||
public NextNDays( Integer numberOfThings ) | ||
{ | ||
super( numberOfThings, 'NEXT_N_DAYS' ); | ||
} | ||
} | ||
|
||
public class LastNWeeks extends NumericallyQualifiedLiteral | ||
{ | ||
public LastNWeeks( Integer numberOfThings ) | ||
{ | ||
super( numberOfThings, 'LAST_N_WEEKS' ); | ||
} | ||
} | ||
|
||
public class NextNWeeks extends NumericallyQualifiedLiteral | ||
{ | ||
public NextNWeeks( Integer numberOfThings ) | ||
{ | ||
super( numberOfThings, 'NEXT_N_WEEKS' ); | ||
} | ||
} | ||
|
||
public class LastNMonths extends NumericallyQualifiedLiteral | ||
{ | ||
public LastNMonths( Integer numberOfThings ) | ||
{ | ||
super( numberOfThings, 'LAST_N_MONTHS' ); | ||
} | ||
} | ||
|
||
public class NextNMonths extends NumericallyQualifiedLiteral | ||
{ | ||
public NextNMonths( Integer numberOfThings ) | ||
{ | ||
super( numberOfThings, 'NEXT_N_MONTHS' ); | ||
} | ||
} | ||
|
||
private abstract class NumericallyQualifiedLiteral implements Literal | ||
{ | ||
Integer numberOfThings; | ||
String baseLiteral; | ||
|
||
protected NumericallyQualifiedLiteral( Integer numberOfThings, String baseLiteral ) | ||
{ | ||
Contract.requires( numberOfThings != null, 'constructor called with a null numberOfThings' ); | ||
Contract.requires( baseLiteral != null, 'constructor called with a null baseLiteral' ); | ||
|
||
this.numberOfThings = numberOfThings; | ||
this.baseLiteral = baseLiteral; | ||
} | ||
|
||
public String toLiteral() | ||
{ | ||
return this.baseLiteral + ':' + this.numberOfThings; | ||
} | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
framework/default/ortoo-core/default/classes/fflib-extension/ortoo_DateLiterals.cls-meta.xml
This file contains 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>52.0</apiVersion> | ||
<status>Active</status> | ||
</ApexClass> |