1 16 17 package info.jtrac.domain; 18 19 import java.io.Serializable ; 20 import java.util.HashMap ; 21 import java.util.Map ; 22 23 27 public class CountsHolder implements Serializable { 28 29 Map <Long , Counts> counts = new HashMap <Long , Counts>(); 30 31 public void add(long spaceId, int type, int state, int count) { 32 Counts c = counts.get(spaceId); 33 if (c == null) { 34 c = new Counts(); 35 counts.put(spaceId, c); 36 } 37 c.add(type, state, count); 38 } 39 40 private int getTotalForType(int type) { 41 int total = 0; 42 for(Counts c : counts.values()) { 43 total += c.getTotalForType(type); 44 } 45 return total; 46 } 47 48 public int getTotalLoggedByMe() { 49 return getTotalForType(Counts.LOGGED_BY_ME); 50 } 51 52 public int getTotalAssignedToMe() { 53 return getTotalForType(Counts.ASSIGNED_TO_ME); 54 } 55 56 public int getTotalTotal() { 57 return getTotalForType(Counts.TOTAL); 58 } 59 60 public Map <Long , Counts> getCounts() { 61 return counts; 62 } 63 64 } 65 | Popular Tags |