Skip to content

Commit 6cb2362

Browse files
authored
Merge pull request #22 from jongpie/feature/issue-16
Feature/issue 16 - merging to master
2 parents 073c2b7 + 058bf17 commit 6cb2362

File tree

7 files changed

+447
-5
lines changed

7 files changed

+447
-5
lines changed

src/classes/DateLiterals.cls

Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
public class DateLiterals {
2+
private final String LAST_N = 'LAST_N_{0}: {1}';
3+
private final String NEXT_N = 'NEXT_N_{0}: {1}';
4+
5+
private final String DAYS = 'DAYS';
6+
private final String WEEKS = 'WEEKS';
7+
private final String MONTHS = 'MONTHS';
8+
private final String QUARTERS = 'QUARTERS';
9+
private final String FISCAL_QUARTERS = 'FISCAL_QUARTERS';
10+
private final String YEARS = 'YEARS';
11+
private final String FISCAL_YEARS = 'FISCAL_YEARS';
12+
13+
public String value {get; private set;}
14+
15+
//Actual constant literals
16+
public DateLiterals YESTERDAY {
17+
get {return this.setValue('YESTERDAY');}
18+
}
19+
20+
public DateLiterals TODAY {
21+
get {return this.setValue('TODAY');}
22+
}
23+
24+
public DateLiterals TOMORROW {
25+
get {return this.setValue('TOMORROW');}
26+
}
27+
28+
public DateLiterals LAST_WEEK {
29+
get {return this.setValue('LAST_WEEK');}
30+
}
31+
32+
public DateLiterals THIS_WEEK {
33+
get {return this.setValue('THIS_WEEK');}
34+
}
35+
36+
public DateLiterals NEXT_WEEK {
37+
get {return this.setValue('NEXT_WEEK');}
38+
}
39+
40+
public DateLiterals LAST_MONTH {
41+
get {return this.setValue('LAST_MONTH');}
42+
}
43+
44+
public DateLiterals THIS_MONTH {
45+
get {return this.setValue('THIS_MONTH');}
46+
}
47+
48+
public DateLiterals NEXT_MONTH {
49+
get {return this.setValue('NEXT_MONTH');}
50+
}
51+
52+
public DateLiterals LAST_90_DAYS {
53+
get {return this.setValue('LAST_90_DAYS');}
54+
}
55+
56+
public DateLiterals NEXT_90_DAYS {
57+
get {return this.setValue('NEXT_90_DAYS');}
58+
}
59+
60+
public DateLiterals THIS_QUARTER {
61+
get {return this.setValue('THIS_QUARTER');}
62+
}
63+
64+
public DateLiterals THIS_FISCAL_QUARTER {
65+
get {return this.setValue('THIS_FISCAL_QUARTER');}
66+
}
67+
68+
public DateLiterals LAST_QUARTER {
69+
get {return this.setValue('LAST_QUARTER');}
70+
}
71+
72+
public DateLiterals LAST_FISCAL_QUARTER {
73+
get {return this.setValue('LAST_FISCAL_QUARTER');}
74+
}
75+
76+
public DateLiterals NEXT_QUARTER {
77+
get {return this.setValue('NEXT_QUARTER');}
78+
}
79+
80+
public DateLiterals NEXT_FISCAL_QUARTER {
81+
get {return this.setValue('NEXT_FISCAL_QUARTER');}
82+
}
83+
84+
public DateLiterals THIS_YEAR {
85+
get {return this.setValue('THIS_YEAR');}
86+
}
87+
88+
public DateLiterals THIS_FISCAL_YEAR {
89+
get {return this.setValue('THIS_FISCAL_YEAR');}
90+
}
91+
92+
public DateLiterals LAST_YEAR {
93+
get {return this.setValue('LAST_YEAR');}
94+
}
95+
96+
public DateLiterals LAST_FISCAL_YEAR {
97+
get {return this.setValue('LAST_FISCAL_YEAR');}
98+
}
99+
100+
public DateLiterals NEXT_YEAR {
101+
get {return this.setValue('NEXT_YEAR');}
102+
}
103+
104+
public DateLiterals NEXT_FISCAL_YEAR {
105+
get {return this.setValue('NEXT_FISCAL_YEAR');}
106+
}
107+
108+
////Buildable literals
109+
public DateLiterals LAST_N_DAYS(Integer num) {
110+
String parsedValue = String.format(LAST_N, new List<String>{DAYS,String.valueOf(num)});
111+
return this.setValue(parsedValue);
112+
}
113+
114+
public DateLiterals LAST_N_WEEKS(Integer num) {
115+
String parsedValue = String.format(LAST_N, new List<String>{WEEKS, String.valueof(num)});
116+
return this.setValue(parsedValue);
117+
}
118+
119+
public DateLiterals LAST_N_MONTHS(Integer num) {
120+
String parsedValue = String.format(LAST_N, new List<String>{MONTHS, String.valueOf(num)});
121+
return this.setValue(parsedValue);
122+
}
123+
124+
public DateLiterals LAST_N_QUARTERS(Integer num) {
125+
String parsedValue = String.format(LAST_N, new List<String>{QUARTERS, String.valueOf(num)});
126+
return this.setValue(parsedValue);
127+
}
128+
129+
public DateLiterals LAST_N_YEARS(Integer num) {
130+
String parsedValue = String.format(LAST_N, new List<String>{YEARS, String.valueOf(num)});
131+
return this.setValue(parsedValue);
132+
}
133+
134+
public DateLiterals LAST_N_FISCAL_YEARS(Integer num) {
135+
String parsedValue = String.format(LAST_N, new List<String>{FISCAL_YEARS, String.valueOf(num)});
136+
return this.setValue(parsedValue);
137+
}
138+
139+
public DateLiterals NEXT_N_DAYS(Integer num) {
140+
String parsedValue = String.format(NEXT_N, new List<String>{DAYS, String.valueOf(num)});
141+
return this.setValue(parsedValue);
142+
}
143+
144+
public DateLiterals NEXT_N_WEEKS(Integer num) {
145+
String parsedValue = String.format(NEXT_N, new List<String>{WEEKS, String.valueOf(num)});
146+
return this.setValue(parsedValue);
147+
}
148+
149+
public DateLiterals NEXT_N_MONTHS(Integer num) {
150+
String parsedValue = String.format(NEXT_N, new List<String>{MONTHS, String.valueOf(num)});
151+
return this.setValue(parsedValue);
152+
}
153+
154+
public DateLiterals NEXT_N_QUARTERS(Integer num) {
155+
String parsedValue = String.format(NEXT_N, new List<String>{QUARTERS, String.valueOf(num)});
156+
return this.setValue(parsedValue);
157+
}
158+
159+
public DateLiterals NEXT_N_FISCAL_QUARTERS(Integer num) {
160+
String parsedValue = String.format(NEXT_N, new List<String>{FISCAL_QUARTERS, String.valueOf(num)});
161+
return this.setValue(parsedValue);
162+
}
163+
164+
public DateLiterals NEXT_N_YEARS(Integer num) {
165+
String parsedValue = String.format(NEXT_N, new List<String>{YEARS, String.valueOf(num)});
166+
return this.setValue(parsedValue);
167+
}
168+
169+
public DateLiterals NEXT_N_FISCAL_YEARS(Integer num) {
170+
String parsedValue = String.format(NEXT_N, new List<String>{FISCAL_YEARS, String.valueOf(num)});
171+
return this.setValue(parsedValue);
172+
}
173+
174+
private DateLiterals setValue(String value) {
175+
this.value = value;
176+
return this;
177+
}
178+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
3+
<apiVersion>38.0</apiVersion>
4+
<status>Active</status>
5+
</ApexClass>

0 commit comments

Comments
 (0)