CustomTimeBucketRegistry implements Serializable { public void register(CustomTimeBucket timeBucket) { register(timeBucket, currentId); } CustomTimeBucketRegistry();  CustomTimeBucketRegistry(int startingId);  CustomTimeBucketRegistry(Int2ObjectMap<CustomTimeBucket> idToTimeBucket);  CustomTimeBucketRegistry(Int2ObjectMap<CustomTimeBucket> idToTimeBucket, int startingId); CustomTimeBucket getTimeBucket(int timeBucketId); Integer getTimeBucketId(CustomTimeBucket timeBucket); CustomTimeBucket getTimeBucket(String text); void register(CustomTimeBucket timeBucket); void register(CustomTimeBucket timeBucket, int timeBucketId); @Override String toString();  }
@Test public void testRegister() { CustomTimeBucketRegistry timeBucketRegistry = new CustomTimeBucketRegistry(); CustomTimeBucket c1m = new CustomTimeBucket(TimeBucket.MINUTE); CustomTimeBucket c1h = new CustomTimeBucket(TimeBucket.HOUR); CustomTimeBucket c1d = new CustomTimeBucket(TimeBucket.DAY); timeBucketRegistry.register(c1m, TimeBucket.MINUTE.ordinal()); timeBucketRegistry.register(c1h, TimeBucket.HOUR.ordinal()); timeBucketRegistry.register(c1d, TimeBucket.DAY.ordinal()); int max = Integer.MIN_VALUE; max = Math.max(max, TimeBucket.MINUTE.ordinal()); max = Math.max(max, TimeBucket.HOUR.ordinal()); max = Math.max(max, TimeBucket.DAY.ordinal()); CustomTimeBucket c5m = new CustomTimeBucket(TimeBucket.MINUTE, 5L); timeBucketRegistry.register(c5m); int timeBucketId = timeBucketRegistry.getTimeBucketId(c5m); Assert.assertEquals(max + 1, timeBucketId); }