public class DeviceCount {
private Id accountId;
private String typeName;
private Integer count;
public DeviceCount (Id accountId, String typeName, Integer count) {
this.accountId = accountId;
this.typeName = typeName;
this.count = count;
}
public DeviceCount(AggregateResult ar) {
this(
(Id)ar.get('accountId'),
String.valueOf(ar.get('typeName'),
Integer.valueOf(ar.get('count'));
}
public String getKey() { return buildKey(accountId, typeName); }
public String getCount() { return this.count; }
public static String buildKey (Id accountId, String typeName) {
return accountId + '-' + typeName);
}
}
Map<String, Integer> deviceCounts = new Map<String, Integer>();
// for agg results
DeviceCount dc = new DeviceCount(accId, typeName, count);
deviceCounts.put(dc.getName(), dc.getCount());