@Test public void testCreateFailsWhenFutureTypeNotValid() { Map<String, String> options = new HashMap<>(); options.put(ProviderFutureFactory.PROVIDER_FUTURE_TYPE_KEY, "super-fast"); try { ProviderFutureFactory.create(options); fail("Should throw IllegalArgumentException"); } catch (IllegalArgumentException iae) {} }
public static ProviderFutureFactory create(Map<String, String> providerOptions) { String futureTypeKey = providerOptions.remove(PROVIDER_FUTURE_TYPE_KEY); if (futureTypeKey == null || futureTypeKey.isEmpty()) { if (Runtime.getRuntime().availableProcessors() < 4) { return new ConservativeProviderFutureFactory(); } else if (isWindows()) { return new BalancedProviderFutureFactory(); } else { return new ProgressiveProviderFutureFactory(); } } switch (futureTypeKey.toLowerCase()) { case CONSERVATIVE: return new ConservativeProviderFutureFactory(); case BALANCED: return new BalancedProviderFutureFactory(); case PROGRESSIVE: return new ProgressiveProviderFutureFactory(); default: throw new IllegalArgumentException( "No ProviderFuture implementation with name " + futureTypeKey + " found"); } }
ProviderFutureFactory { public static ProviderFutureFactory create(Map<String, String> providerOptions) { String futureTypeKey = providerOptions.remove(PROVIDER_FUTURE_TYPE_KEY); if (futureTypeKey == null || futureTypeKey.isEmpty()) { if (Runtime.getRuntime().availableProcessors() < 4) { return new ConservativeProviderFutureFactory(); } else if (isWindows()) { return new BalancedProviderFutureFactory(); } else { return new ProgressiveProviderFutureFactory(); } } switch (futureTypeKey.toLowerCase()) { case CONSERVATIVE: return new ConservativeProviderFutureFactory(); case BALANCED: return new BalancedProviderFutureFactory(); case PROGRESSIVE: return new ProgressiveProviderFutureFactory(); default: throw new IllegalArgumentException( "No ProviderFuture implementation with name " + futureTypeKey + " found"); } } }
ProviderFutureFactory { public static ProviderFutureFactory create(Map<String, String> providerOptions) { String futureTypeKey = providerOptions.remove(PROVIDER_FUTURE_TYPE_KEY); if (futureTypeKey == null || futureTypeKey.isEmpty()) { if (Runtime.getRuntime().availableProcessors() < 4) { return new ConservativeProviderFutureFactory(); } else if (isWindows()) { return new BalancedProviderFutureFactory(); } else { return new ProgressiveProviderFutureFactory(); } } switch (futureTypeKey.toLowerCase()) { case CONSERVATIVE: return new ConservativeProviderFutureFactory(); case BALANCED: return new BalancedProviderFutureFactory(); case PROGRESSIVE: return new ProgressiveProviderFutureFactory(); default: throw new IllegalArgumentException( "No ProviderFuture implementation with name " + futureTypeKey + " found"); } }  }
ProviderFutureFactory { public static ProviderFutureFactory create(Map<String, String> providerOptions) { String futureTypeKey = providerOptions.remove(PROVIDER_FUTURE_TYPE_KEY); if (futureTypeKey == null || futureTypeKey.isEmpty()) { if (Runtime.getRuntime().availableProcessors() < 4) { return new ConservativeProviderFutureFactory(); } else if (isWindows()) { return new BalancedProviderFutureFactory(); } else { return new ProgressiveProviderFutureFactory(); } } switch (futureTypeKey.toLowerCase()) { case CONSERVATIVE: return new ConservativeProviderFutureFactory(); case BALANCED: return new BalancedProviderFutureFactory(); case PROGRESSIVE: return new ProgressiveProviderFutureFactory(); default: throw new IllegalArgumentException( "No ProviderFuture implementation with name " + futureTypeKey + " found"); } }  static ProviderFutureFactory create(Map<String, String> providerOptions); abstract ProviderFuture createFuture(); abstract ProviderFuture createFuture(ProviderSynchronization synchronization); abstract ProviderFuture createUnfailableFuture(); }
ProviderFutureFactory { public static ProviderFutureFactory create(Map<String, String> providerOptions) { String futureTypeKey = providerOptions.remove(PROVIDER_FUTURE_TYPE_KEY); if (futureTypeKey == null || futureTypeKey.isEmpty()) { if (Runtime.getRuntime().availableProcessors() < 4) { return new ConservativeProviderFutureFactory(); } else if (isWindows()) { return new BalancedProviderFutureFactory(); } else { return new ProgressiveProviderFutureFactory(); } } switch (futureTypeKey.toLowerCase()) { case CONSERVATIVE: return new ConservativeProviderFutureFactory(); case BALANCED: return new BalancedProviderFutureFactory(); case PROGRESSIVE: return new ProgressiveProviderFutureFactory(); default: throw new IllegalArgumentException( "No ProviderFuture implementation with name " + futureTypeKey + " found"); } }  static ProviderFutureFactory create(Map<String, String> providerOptions); abstract ProviderFuture createFuture(); abstract ProviderFuture createFuture(ProviderSynchronization synchronization); abstract ProviderFuture createUnfailableFuture(); static final String PROVIDER_FUTURE_TYPE_KEY; }