public abstract class

IdStoringStrategy

extends Object
java.lang.Object
   ↳ org.apache.commons.betwixt.strategy.IdStoringStrategy
Known Direct Subclasses

Class Overview

Pluggable strategy for id storage management. It is possible to use this strategy for innovative active storage storage strategies as well as passive ones. For example, it is possible to have some beans map to references without ever being fully mapped.

Summary

Fields
public static IdStoringStrategy DEFAULT This field is deprecated. do not use this singleton since it creates a static Map of all objects ever written. Use createDefault() instead
Public Constructors
IdStoringStrategy()
Public Methods
static IdStoringStrategy createDefault()
Factory method creates the default Betwixt implementation.
abstract String getReferenceFor(Context context, Object bean)
Retrieves a reference for the given instance.
abstract Object getReferenced(Context context, String id)
Gets an object matching the given reference.
abstract void reset()
Reset to the initial state.
abstract void setReference(Context context, Object bean, String id)
Stores an instance reference for later retrieval.
[Expand]
Inherited Methods
From class java.lang.Object

Fields

public static IdStoringStrategy DEFAULT

This field is deprecated.
do not use this singleton since it creates a static Map of all objects ever written. Use createDefault() instead

Default storage strategy

Public Constructors

public IdStoringStrategy ()

Public Methods

public static IdStoringStrategy createDefault ()

Factory method creates the default Betwixt implementation. The implementation created may vary if the default implementation changes.

Returns
  • IdStoringStrategy used as default

public abstract String getReferenceFor (Context context, Object bean)

Retrieves a reference for the given instance. If a not null value is returned from this method, then the bean content will not be written. Use IDGenerator strategy to vary the values written for a bean.

Parameters
context current context, not null
bean the instance, not null
Returns
  • id as String when this bean has already been reference, or null to indicate that this bean is not yet reference

public abstract Object getReferenced (Context context, String id)

Gets an object matching the given reference.

Parameters
context Context, not null
id the reference id
Returns
  • an bean matching the given reference, or null if there is no bean matching the given reference

public abstract void reset ()

Reset to the initial state.

public abstract void setReference (Context context, Object bean, String id)

Stores an instance reference for later retrieval. This method is shared by writing and reading.

Parameters
context current context, not null
bean the instance, not null
id the id to use