I decided to convert a couple of static final maps in my App Engine project to Immutable ones instead. Previously I was using this method to create and initialise maps:
public static final Map<String, Calendar> iterations = new HashMap<String, Calendar>() {{ put(TEAM_A, new GregorianCalendar(2009,9,5)); put(TEAM_B, new GregorianCalendar(2009,8,15)); put(TEAM_C, new GregorianCalendar(2009,7,21)); }};
Now I have this:
public static final Map<String, Calendar> ITERATIONS = new ImmutableMap.Builder<String, Calendar>(). put(TEAM_A, new GregorianCalendar(2009,9,5)). put(TEAM_B, new GregorianCalendar(2009,8,15)). put(TEAM_C, new GregorianCalendar(2009,7,21)). build();
No comments:
Post a Comment