public class DefaultIdStoringStrategy extends IdStoringStrategy
Stores every ID that given to it into an internal HashMap and
returns it on request.
DefaultIdStoringStrategy(Map, Map) allows the implementations
to be specified.
For example, those who want to use identity (rather than equality)
should pass a IdentityHashMap instance.
DEFAULT| Constructor and Description |
|---|
DefaultIdStoringStrategy()
Constructs a
IdStoringStrategy using a HashMap for
storage. |
DefaultIdStoringStrategy(Map idByBeanMap,
Map beanByIdMap)
Constructs a
IdStoringStrategyusing the Map
implementations provided for storage. |
| Modifier and Type | Method and Description |
|---|---|
Object |
getReferenced(Context context,
String id)
Gets an object matching the given reference.
|
String |
getReferenceFor(Context context,
Object bean)
Returns a String id for the given bean if it has been stored previously.
|
void |
reset()
Clears all beans.
|
void |
setReference(Context context,
Object bean,
String id)
Stores an ID for the given instance and context.
|
createDefaultpublic DefaultIdStoringStrategy()
IdStoringStrategy using a HashMap for
storage.public DefaultIdStoringStrategy(Map idByBeanMap, Map beanByIdMap)
IdStoringStrategyusing the Map
implementations provided for storage.idByBeanMap - Map implementation stores the ID's by beanbeanByIdMap - Map implementation stores the bean's by IDpublic String getReferenceFor(Context context, Object bean)
getReferenceFor in class IdStoringStrategycontext - current context, not nullbean - the instance, not nullIdStoringStrategy.getReferenceFor(org.apache.commons.betwixt.expression.Context,
java.lang.Object)public void setReference(Context context, Object bean, String id)
setReference in class IdStoringStrategycontext - current context, not nullbean - current instance, not nullid - the ID to storeIdStoringStrategy.setReference(org.apache.commons.betwixt.expression.Context,
java.lang.Object, java.lang.String)public Object getReferenced(Context context, String id)
getReferenced in class IdStoringStrategycontext - Context, not nullid - the reference idpublic void reset()
reset in class IdStoringStrategyCopyright © 2002-2013 Apache Software Foundation. All Rights Reserved.