Class StrategyRegistry<A>
- java.lang.Object
- 
- org.apache.tapestry5.commons.util.StrategyRegistry<A>
 
- 
- Type Parameters:
- A- the type of the strategy adapter
 
 public final class StrategyRegistry<A> extends Object A key component in implementing the "Gang of Four" Strategy pattern. A StrategyRegistry will match up a given input type with a registered strategy for that type.
- 
- 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclearCache()Aget(Class type)Searches for an adapter corresponding to the given input type.Class<A>getAdapterType()AgetByInstance(Object value)Gets an adapter for an object.Collection<Class>getTypes()Returns the registered types for which adapters are available.static <A> StrategyRegistry<A>newInstance(Class<A> adapterType, Map<Class,A> registrations)Creates a strategy registry for the given adapter type.static <A> StrategyRegistry<A>newInstance(Class<A> adapterType, Map<Class,A> registrations, boolean allowNonMatch)Creates a strategy registry for the given adapter type.StringtoString()
 
- 
- 
- 
Method Detail- 
newInstancepublic static <A> StrategyRegistry<A> newInstance(Class<A> adapterType, Map<Class,A> registrations) Creates a strategy registry for the given adapter type. The registry will be configured to require matches.- Parameters:
- adapterType- the type of adapter retrieved from the registry
- registrations- map of registrations (the contents of the map are copied)
 
 - 
newInstancepublic static <A> StrategyRegistry<A> newInstance(Class<A> adapterType, Map<Class,A> registrations, boolean allowNonMatch) Creates a strategy registry for the given adapter type.- Parameters:
- adapterType- the type of adapter retrieved from the registry
- registrations- map of registrations (the contents of the map are copied)
- allowNonMatch- if true, then the registry supports non-matches when retrieving an adapter
 
 - 
clearCachepublic void clearCache() 
 - 
getAdapterTypepublic Class<A> getAdapterType() 
 - 
getByInstancepublic A getByInstance(Object value) Gets an adapter for an object. Searches based on the value's class, unless the value is null, in which case, a search on class void is used.- Parameters:
- value- for which an adapter is needed
- Returns:
- the adapter for the value or null if not found (and allowNonMatch is true)
- Throws:
- IllegalArgumentException- if no matching adapter may be found and allowNonMatch is false
 
 - 
getpublic A get(Class type) Searches for an adapter corresponding to the given input type.- Parameters:
- type- the type to search
- Returns:
- the adapter for the type or null if not found (and allowNonMatch is true)
- Throws:
- IllegalArgumentException- if no matching adapter may be found and allowNonMatch is false
 
 - 
getTypespublic Collection<Class> getTypes() Returns the registered types for which adapters are available.
 
- 
 
-