@Override public final V apply(K key) { return autoDelegate.apply(key); }
@Override public final V apply(K key) { return autoDelegate.apply(key); }
@Override public final V apply(K key) { return autoDelegate.apply(key); }
@Override public V apply(K key) { return delegate().apply(key); }
@Override public V apply(K key) { return delegate().apply(key); }
@Override public V apply(K key) { return delegate().apply(key); }
public void testLoadingCache() throws ExecutionException { CacheLoader<Integer, Integer> loader = new CacheLoader<Integer, Integer>() { int i = 0; @Override public Integer load(Integer key) throws Exception { return i++; } }; LoadingCache<Integer, Integer> cache = CacheBuilder.newBuilder().build(loader); cache.put(10, 20); Map<Integer, Integer> map = cache.getAll(ImmutableList.of(10, 20, 30, 54, 443, 1)); assertEquals(Integer.valueOf(20), map.get(10)); assertEquals(Integer.valueOf(0), map.get(20)); assertEquals(Integer.valueOf(1), map.get(30)); assertEquals(Integer.valueOf(2), map.get(54)); assertEquals(Integer.valueOf(3), map.get(443)); assertEquals(Integer.valueOf(4), map.get(1)); assertEquals(Integer.valueOf(5), cache.get(6)); assertEquals(Integer.valueOf(6), cache.apply(7)); }
@SuppressWarnings("deprecation") public void testLoadingCache() throws ExecutionException { CacheLoader<Integer, Integer> loader = new CacheLoader<Integer, Integer>() { int i = 0; @Override public Integer load(Integer key) throws Exception { return i++; } }; LoadingCache<Integer, Integer> cache = CaffeinatedGuava.build(Caffeine.newBuilder(), loader); cache.put(10, 20); ImmutableSet<Integer> keys = ImmutableSet.of(10, 20, 30, 54, 443, 1); Map<Integer, Integer> map = cache.getAll(keys); // Original test depended on order, but that was only expected for the emulated implementation assertEquals(keys, map.keySet()); assertEquals(ImmutableSet.of(0, 1, 2, 3, 4, 20), ImmutableSet.copyOf(map.values())); assertEquals(Integer.valueOf(5), cache.get(6)); assertEquals(Integer.valueOf(6), cache.apply(7)); }
/** * @see ReferenceTypePredicates#typeEquals */ public static Predicate<Link> typeEquals(String type) { return MEDIA_TYPE_SELECTORS.apply(type); }
/** * @see ReferenceTypePredicates#nameEquals */ public static Predicate<Link> nameEquals(String name) { return MEDIA_NAME_SELECTORS.apply(name); }
@Override public final V apply(K key) { return autoDelegate.apply(key); }
public SecurityGroup createSecurityGroup(String name) { checkNotNull(name, "name"); NetworkAndAddressRange nAr = new NetworkAndAddressRange(name, DEFAULT_INTERNAL_NETWORK_RANGE, null); Network nw = networkCreator.apply(nAr); return groupConverter.apply(nw); }
public SecurityGroup createSecurityGroup(String name) { checkNotNull(name, "name"); NetworkAndAddressRange nAr = new NetworkAndAddressRange(name, DEFAULT_INTERNAL_NETWORK_RANGE, null); Network nw = networkCreator.apply(nAr); return groupConverter.apply(nw); }
@Override public V apply(K key) { return delegate().apply(key); }
private void populateCredentials(Set<RunningInstance> input, TemplateOptions options) { LoginCredentials credentials = null; for (RunningInstance instance : input) { credentials = instanceToCredentials.apply(instance).orNull(); if (credentials != null) break; } credentials = overrideDefaultCredentialsWithOptionsIfPresent(credentials, options); if (credentials != null) for (RegionAndName instance : transform(input, instanceToRegionAndName)) credentialStore.put("node#" + instance.slashEncode(), credentials); }
private void populateCredentials(Set<RunningInstance> input, TemplateOptions options) { LoginCredentials credentials = null; for (RunningInstance instance : input) { credentials = instanceToCredentials.apply(instance).orNull(); if (credentials != null) break; } credentials = overrideDefaultCredentialsWithOptionsIfPresent(credentials, options); if (credentials != null) for (RegionAndName instance : transform(input, instanceToRegionAndName)) credentialStore.put("node#" + instance.slashEncode(), credentials); }
/** * Try and find a network either previously created by jclouds or user defined. */ private Network getOrCreateNetwork(GoogleComputeEngineTemplateOptions templateOptions, String sharedResourceName) { String networkName = templateOptions.getNetworkName().or(sharedResourceName); return networkMap.apply(new NetworkAndAddressRange(networkName, DEFAULT_INTERNAL_NETWORK_RANGE, null)); }
/** * Try and find a network either previously created by jclouds or user defined. */ private Network getOrCreateNetwork(GoogleComputeEngineTemplateOptions templateOptions, String sharedResourceName) { String networkName = templateOptions.getNetworkName().or(sharedResourceName); return networkMap.apply(new NetworkAndAddressRange(networkName, DEFAULT_INTERNAL_NETWORK_RANGE, null)); }
public void testCacheLoadLogsIn() { SessionApi sessionApi = createMock(SessionApi.class); expect(sessionApi.login(creds)).andReturn(session); replay(sessionApi); assertSame(SessionManager.buildCache(sessionApi).apply(creds), session); verify(sessionApi); }