org.jclouds.suppliers
Class SupplyKeyMatchingValueOrNull<K,V>

java.lang.Object
  extended by org.jclouds.suppliers.SupplyKeyMatchingValueOrNull<K,V>
All Implemented Interfaces:
com.google.common.base.Supplier<K>
Direct Known Subclasses:
GetRegionIdMatchingProviderURIOrNull

public class SupplyKeyMatchingValueOrNull<K,V>
extends Object
implements com.google.common.base.Supplier<K>

Allows you to lazy discover a key by value. This is useful for example in service discovery, where you need to see what the "current" service name is based on a map of service names to endpoints.

note

take care to memoize this using Suppliers.memoize(Supplier)

Author:
Adrian Cole

Field Summary
protected  Logger logger
           
 
Constructor Summary
SupplyKeyMatchingValueOrNull(com.google.common.base.Supplier<Map<K,com.google.common.base.Supplier<V>>> supplier, com.google.common.base.Supplier<V> valueSupplier)
           
 
Method Summary
 K get()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected Logger logger
Constructor Detail

SupplyKeyMatchingValueOrNull

public SupplyKeyMatchingValueOrNull(com.google.common.base.Supplier<Map<K,com.google.common.base.Supplier<V>>> supplier,
                                    com.google.common.base.Supplier<V> valueSupplier)
Method Detail

get

public K get()
Specified by:
get in interface com.google.common.base.Supplier<K>


Copyright © 2009-2012 jclouds. All Rights Reserved.