@Nonnull private <T> T newInstanceOf(@Nonnull Class<T> type) { requireNonNull("type", type); final Constructor<T> constructor; try { constructor = type.getConstructor(); } catch (Exception e) { throw new IllegalArgumentException( "Could not find a default constructor for " + type.getName() + ".", e); } if (!constructor.isAccessible()) { try { constructor.setAccessible(true); } catch (Exception e) { throw new RuntimeException( "Could not access the default constructor for " + type.getName() + ".", e); } } try { return constructor.newInstance(); } catch (Exception e) { throw new RuntimeException("Could not create an instance of " + type.getName() + ".", e); } }