test_class.file: ch-commons-util/src/test/java/com/cloudhopper/commons/util/time/DateTimePeriodDataUtilTest.java
test_class.identifier: DateTimePeriodDataUtilTest
test_case.body: @Test
      public void fill() throws Exception {
          //
          // create a period of 4 hours
          //
          DateTime start = new DateTime(2009, 1, 1, 0, 0, 0, 0, DateTimeZone.UTC);
          DateTimePeriod period = new DateTimeHour(start, start.plusHours(4));
  
          // fill an empty map
          TreeMap<DateTime, SampleData> emptyMap = new TreeMap<DateTime, SampleData>();
          DateTimePeriodDataUtil.fill(SampleData.class, emptyMap, period.toHours());
  
          SampleData[] result0 = emptyMap.values().toArray(new SampleData[0]);
          Assert.assertArrayEquals(new SampleData[] {
              new SampleData(DateTimePeriod.createHour(2009, 1, 1, 0, DateTimeZone.UTC), null),
              new SampleData(DateTimePeriod.createHour(2009, 1, 1, 1, DateTimeZone.UTC), null),
              new SampleData(DateTimePeriod.createHour(2009, 1, 1, 2, DateTimeZone.UTC), null),
              new SampleData(DateTimePeriod.createHour(2009, 1, 1, 3, DateTimeZone.UTC), null)
          }, result0);
  
          // fill a partially completed map
          SampleData hour0 = new SampleData(DateTimePeriod.createHour(2009, 1, 1, 0, DateTimeZone.UTC), "hour0");
          SampleData hour2 = new SampleData(DateTimePeriod.createHour(2009, 1, 1, 2, DateTimeZone.UTC), "hour2");
          TreeMap<DateTime, SampleData> partialMap = new TreeMap<DateTime, SampleData>();
          partialMap.put(hour0.getPeriod().getStart(), hour0);
          partialMap.put(hour2.getPeriod().getStart(), hour2);
          DateTimePeriodDataUtil.fill(SampleData.class, partialMap, period.toHours());
  
          result0 = partialMap.values().toArray(new SampleData[0]);
          Assert.assertArrayEquals(new SampleData[] {
              new SampleData(DateTimePeriod.createHour(2009, 1, 1, 0, DateTimeZone.UTC), "hour0"),
              new SampleData(DateTimePeriod.createHour(2009, 1, 1, 1, DateTimeZone.UTC), null),
              new SampleData(DateTimePeriod.createHour(2009, 1, 1, 2, DateTimeZone.UTC), "hour2"),
              new SampleData(DateTimePeriod.createHour(2009, 1, 1, 3, DateTimeZone.UTC), null)
          }, result0);
  
      }
test_case.class_method_signature: DateTimePeriodDataUtilTest.fill()
test_case.full_signature: @Test public void fill()
test_case.identifier: fill
test_case.invocations: plusHours fill toHours toArray values assertArrayEquals createHour createHour createHour createHour createHour createHour put getStart getPeriod put getStart getPeriod fill toHours toArray values assertArrayEquals createHour createHour createHour createHour
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void fill()
focal_class.file: ch-commons-util/src/main/java/com/cloudhopper/commons/util/time/DateTimePeriodDataUtil.java
focal_class.identifier: DateTimePeriodDataUtil
focal_class.class_method_signature: DateTimePeriodDataUtil.DateTimePeriodDataUtil()
focal_class.full_signature: private  DateTimePeriodDataUtil()
focal_class.identifier: DateTimePeriodDataUtil
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.signature:  DateTimePeriodDataUtil()
focal_class.class_method_signature: DateTimePeriodDataUtil.fill(Class<T> type, Map<DateTime,T> dataset, List<DateTimePeriod> periods)
focal_class.full_signature: @SuppressWarnings("unchecked") public static void fill(Class<T> type, Map<DateTime,T> dataset, List<DateTimePeriod> periods)
focal_class.identifier: fill
focal_class.modifiers: @SuppressWarnings("unchecked") public static
focal_class.parameters: (Class<T> type, Map<DateTime,T> dataset, List<DateTimePeriod> periods)
focal_class.return: void
focal_class.signature: void fill(Class<T> type, Map<DateTime,T> dataset, List<DateTimePeriod> periods)
focal_method.body: @SuppressWarnings("unchecked")
      public static <T extends DateTimePeriodData> void fill(Class<T> type, Map<DateTime,T> dataset, List<DateTimePeriod> periods) {
          // loop thru every period, check its it starting time exists in the dataset
          for (DateTimePeriod period : periods) {
              if (dataset.containsKey(period.getStart())) {
                  // do nothing
              } else {
                  // add a default entry
                  try {
                      Constructor ctor = type.getConstructor(DateTimePeriod.class);
                      T data = (T)ctor.newInstance(period);
                      dataset.put(period.getStart(), data);
                  } catch (Exception e) {
                      throw new RuntimeException("Failed to create default dataset entry", e);
                  }
              }
          }
      }
focal_method.class_method_signature: DateTimePeriodDataUtil.fill(Class<T> type, Map<DateTime,T> dataset, List<DateTimePeriod> periods)
focal_method.full_signature: @SuppressWarnings("unchecked") public static void fill(Class<T> type, Map<DateTime,T> dataset, List<DateTimePeriod> periods)
focal_method.identifier: fill
focal_method.invocations: containsKey getStart getConstructor newInstance put getStart
focal_method.modifiers: @SuppressWarnings("unchecked") public static
focal_method.parameters: (Class<T> type, Map<DateTime,T> dataset, List<DateTimePeriod> periods)
focal_method.return: void
focal_method.signature: void fill(Class<T> type, Map<DateTime,T> dataset, List<DateTimePeriod> periods)