Пример #1
0
 // NOTE: K is used by DataStoreInterface, end up with L and M
 public <L extends Enum<L>, M extends Enum<M>> void pivot(
     EnumMap<L, EnumMap<M, ArrayList<SinglePlay>>> plays,
     Class<L> firstEnumType,
     Class<M> secondEnumType) {
   /* Need to iterate through the map and extract the wanted value
   from each play. If an entry does not already exist in the
   result map, have to add it, and then insert the play */
   Iterator<SinglePlay> index = _plays.iterator();
   while (index.hasNext()) {
     SinglePlay testPlay = index.next();
     L firstWantValue = testPlay.getValue(firstEnumType);
     M secondWantValue = testPlay.getValue(secondEnumType);
     if ((firstWantValue != null) && (secondWantValue != null)) { // Play has value in wanted types
       EnumMap<M, ArrayList<SinglePlay>> wantMap = plays.get(firstWantValue);
       if (wantMap == null) {
         /* NOTE: creating an enum map of M here, so need the
         second enumerated type, not the first */
         wantMap = new EnumMap<M, ArrayList<SinglePlay>>(secondEnumType);
         plays.put(firstWantValue, wantMap);
       }
       ArrayList<SinglePlay> wantList = wantMap.get(secondWantValue);
       if (wantList == null) {
         wantList = new ArrayList<SinglePlay>();
         wantMap.put(secondWantValue, wantList);
       }
       wantList.add(testPlay);
     } // Play has value in wanted type
   } // While plays to process
 } // Rollup method
Пример #2
0
 // NOTE: K is used by DataStoreInterface, end up with L
 public <L extends Enum<L>> void pivot(
     EnumMap<L, ArrayList<SinglePlay>> plays, Class<L> enumType) {
   /* Need to iterate through the map and extract the wanted value
   from each play. If an entry does not already exist in the
   result map, have to add it, and then insert the play */
   Iterator<SinglePlay> index = _plays.iterator();
   while (index.hasNext()) {
     SinglePlay testPlay = index.next();
     L wantValue = testPlay.getValue(enumType);
     if (wantValue != null) { // Play has value in wanted type
       ArrayList<SinglePlay> wantList = plays.get(wantValue);
       if (wantList == null) {
         wantList = new ArrayList<SinglePlay>();
         plays.put(wantValue, wantList);
       }
       wantList.add(testPlay);
     } // Play has value in wanted type
   } // While plays to process
 }