@Test(expected=RuntimeException.class) public void shouldCreationWithConsolidatorDefiningFailingConstructorBeInvalid() { Consolidators.createConsolidator(ConsolidatorWithFailingConstructor.class, 1); }
public static Consolidator createConsolidator(final Class<? extends Consolidator> type, final int maxSamples) { Preconditions.checkNotNull(type, "null type"); Preconditions2.checkSize(maxSamples); try { try { return type.getConstructor(int.class).newInstance(maxSamples); } catch (NoSuchMethodException e) { if (Loggers.BASE_LOGGER.isLoggable(Level.FINEST)) { Loggers.BASE_LOGGER.log(Level.FINEST, "{0} does not define a constructor accepting int", type.getCanonicalName()); } } try { final Constructor<? extends Consolidator> defaultConstructor = type.getConstructor(); return defaultConstructor.newInstance(); } catch (NoSuchMethodException e) { throw new IllegalArgumentException("Failed to find int or default constructor for "+type.getCanonicalName(), e); } } catch (ReflectiveOperationException e) { throw new RuntimeException(e); } }
Consolidators { public static Consolidator createConsolidator(final Class<? extends Consolidator> type, final int maxSamples) { Preconditions.checkNotNull(type, "null type"); Preconditions2.checkSize(maxSamples); try { try { return type.getConstructor(int.class).newInstance(maxSamples); } catch (NoSuchMethodException e) { if (Loggers.BASE_LOGGER.isLoggable(Level.FINEST)) { Loggers.BASE_LOGGER.log(Level.FINEST, "{0} does not define a constructor accepting int", type.getCanonicalName()); } } try { final Constructor<? extends Consolidator> defaultConstructor = type.getConstructor(); return defaultConstructor.newInstance(); } catch (NoSuchMethodException e) { throw new IllegalArgumentException("Failed to find int or default constructor for "+type.getCanonicalName(), e); } } catch (ReflectiveOperationException e) { throw new RuntimeException(e); } } }
Consolidators { public static Consolidator createConsolidator(final Class<? extends Consolidator> type, final int maxSamples) { Preconditions.checkNotNull(type, "null type"); Preconditions2.checkSize(maxSamples); try { try { return type.getConstructor(int.class).newInstance(maxSamples); } catch (NoSuchMethodException e) { if (Loggers.BASE_LOGGER.isLoggable(Level.FINEST)) { Loggers.BASE_LOGGER.log(Level.FINEST, "{0} does not define a constructor accepting int", type.getCanonicalName()); } } try { final Constructor<? extends Consolidator> defaultConstructor = type.getConstructor(); return defaultConstructor.newInstance(); } catch (NoSuchMethodException e) { throw new IllegalArgumentException("Failed to find int or default constructor for "+type.getCanonicalName(), e); } } catch (ReflectiveOperationException e) { throw new RuntimeException(e); } } private  Consolidators(); }
Consolidators { public static Consolidator createConsolidator(final Class<? extends Consolidator> type, final int maxSamples) { Preconditions.checkNotNull(type, "null type"); Preconditions2.checkSize(maxSamples); try { try { return type.getConstructor(int.class).newInstance(maxSamples); } catch (NoSuchMethodException e) { if (Loggers.BASE_LOGGER.isLoggable(Level.FINEST)) { Loggers.BASE_LOGGER.log(Level.FINEST, "{0} does not define a constructor accepting int", type.getCanonicalName()); } } try { final Constructor<? extends Consolidator> defaultConstructor = type.getConstructor(); return defaultConstructor.newInstance(); } catch (NoSuchMethodException e) { throw new IllegalArgumentException("Failed to find int or default constructor for "+type.getCanonicalName(), e); } } catch (ReflectiveOperationException e) { throw new RuntimeException(e); } } private  Consolidators(); static Consolidator createConsolidator(final Class<? extends Consolidator> type, final int maxSamples); static Consolidator[] createConsolidators(final List<? extends Class<? extends Consolidator>> consolidatorTypes, final int maxSamples); }
Consolidators { public static Consolidator createConsolidator(final Class<? extends Consolidator> type, final int maxSamples) { Preconditions.checkNotNull(type, "null type"); Preconditions2.checkSize(maxSamples); try { try { return type.getConstructor(int.class).newInstance(maxSamples); } catch (NoSuchMethodException e) { if (Loggers.BASE_LOGGER.isLoggable(Level.FINEST)) { Loggers.BASE_LOGGER.log(Level.FINEST, "{0} does not define a constructor accepting int", type.getCanonicalName()); } } try { final Constructor<? extends Consolidator> defaultConstructor = type.getConstructor(); return defaultConstructor.newInstance(); } catch (NoSuchMethodException e) { throw new IllegalArgumentException("Failed to find int or default constructor for "+type.getCanonicalName(), e); } } catch (ReflectiveOperationException e) { throw new RuntimeException(e); } } private  Consolidators(); static Consolidator createConsolidator(final Class<? extends Consolidator> type, final int maxSamples); static Consolidator[] createConsolidators(final List<? extends Class<? extends Consolidator>> consolidatorTypes, final int maxSamples);  }