-
Notifications
You must be signed in to change notification settings - Fork 0
/
AccountWrapperMul.cls
48 lines (35 loc) · 1.5 KB
/
AccountWrapperMul.cls
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*====================================================================
SELECT AnnualRevenue, Type, Name
FROM Account
ORDER BY AnnualRevenue Desc NULLS LAST,
Type Asc NULLS LAST,
Name Asc NULLS LAST
====================================================================*/
public class AccountWrapperMul implements Comparable{
public String Name;
public String Type;
public Double AnnualRevenue;
public AccountWrapperMul(Account Acc){
Name = Acc.Name;
Type = Acc.Type;
AnnualRevenue = Acc.AnnualRevenue;
}
public Integer compareTo(Object compareTo){
AccountWrapperMul compareToAccount = (AccountWrapperMul)compareTo;
if(AnnualRevenue == compareToAccount.AnnualRevenue){
if(Type == compareToAccount.Type) {
if(Name == compareToAccount.Name) return 0;
if(Name == null) return 1;
if(compareToAccount.Name == null) return -1;
return Name.compareTo(compareToAccount.Name);
}
if(Type == null) return 1;
if(compareToAccount.Type == null) return -1;
return Type.compareTo(compareToAccount.Type);
} else if(AnnualRevenue == null || AnnualRevenue < compareToAccount.AnnualRevenue){
return 1;
} else {
return -1;
}
}
}