Пример #1
0
 ImmutableMap<Service, Long> startupTimes() {
   List<Entry<Service, Long>> loadTimes;
   monitor.enter();
   try {
     loadTimes = Lists.newArrayListWithCapacity(startupTimers.size());
     // N.B. There will only be an entry in the map if the service has started
     for (Entry<Service, Stopwatch> entry : startupTimers.entrySet()) {
       Service service = entry.getKey();
       Stopwatch stopWatch = entry.getValue();
       if (!stopWatch.isRunning() && !(service instanceof NoOpService)) {
         loadTimes.add(Maps.immutableEntry(service, stopWatch.elapsed(MILLISECONDS)));
       }
     }
   } finally {
     monitor.leave();
   }
   Collections.sort(
       loadTimes,
       Ordering.<Long>natural()
           .onResultOf(
               new Function<Entry<Service, Long>, Long>() {
                 @Override
                 public Long apply(Map.Entry<Service, Long> input) {
                   return input.getValue();
                 }
               }));
   ImmutableMap.Builder<Service, Long> builder = ImmutableMap.builder();
   for (Entry<Service, Long> entry : loadTimes) {
     builder.put(entry);
   }
   return builder.build();
 }
Пример #2
0
 static {
   ImmutableMap.Builder<Integer, DRRecordType> b = ImmutableMap.builder();
   for (DRRecordType t : DRRecordType.values()) {
     b.put(t.ordinal(), t);
   }
   conversion = b.build();
 }
Пример #3
0
 static {
   ImmutableMap.Builder<String, Method> builder = ImmutableMap.builder();
   for (Method method : TypeVariableImpl.class.getMethods()) {
     if (method.getDeclaringClass().equals(TypeVariableImpl.class)) {
       try {
         method.setAccessible(true);
       } catch (AccessControlException e) {
         // OK: the method is accessible to us anyway. The setAccessible call is only for
         // unusual execution environments where that might not be true.
       }
       builder.put(method.getName(), method);
     }
   }
   typeVariableMethods = builder.build();
 }