com.anasoft.os.daofusion.bitemporal
Class BitemporalWrapper<V>

java.lang.Object
  extended by com.anasoft.os.daofusion.entity.PersistentEntity<java.lang.Long>
      extended by com.anasoft.os.daofusion.entity.MutablePersistentEntity
          extended by com.anasoft.os.daofusion.bitemporal.BitemporalWrapper<V>
Type Parameters:
V - Value tracked by BitemporalTrace.
All Implemented Interfaces:
Bitemporal, Persistable<java.lang.Long>, java.io.Serializable

public abstract class BitemporalWrapper<V>
extends MutablePersistentEntity
implements Bitemporal

Decorates a value with bitemporal information, making it possible to bitemporally track the value in a BitemporalTrace. A BitemporalWrapper allows you to bitemporally track existing value classes, for instance strings. This class implements the Bitemporal interface for use with JPA / Hibernate.

Due to the nature of bitemporality, the wrapped value should be immutable. The value itself will never change, instead new values will be added to the BitemporalTrace to represent changes of the value. A BitemporalWrapper itself is not immutable, its record interval can be ended.

Instances of this class are serializable if the wrapped value is serializable.

Objects of this class are not thread-safe.

Author:
Erwin Vervaet, Christophe Vanfleteren, igor.mihalik
See Also:
Bitemporal, BitemporalTrace, Serialized Form

Field Summary
static java.lang.String _RECORD_FROM
           
static java.lang.String _RECORD_TO
           
static java.lang.String _VALID_FROM
           
static java.lang.String _VALID_TO
           
 
Fields inherited from class com.anasoft.os.daofusion.entity.PersistentEntity
_ID
 
Constructor Summary
protected BitemporalWrapper()
           
  BitemporalWrapper(V value, org.joda.time.Interval validityInterval)
          Bitemporally wrap the given value.
 
Method Summary
 void end()
          End the recording interval of this bitemporal object, indicating that it has been superseded by a new object, or is deemed as no longer relevant (i.e. because it was faulty knowledge) and should be "forgotten".
 org.joda.time.Interval getRecordInterval()
          Returns the interval in which this bitemporal object is known.
 org.joda.time.Interval getValidityInterval()
          Returns the interval in which this bitemporal object is valid.
abstract  V getValue()
          Returns the wrapped value, possibly null.
protected  void setValidityInterval(org.joda.time.Interval validityInterval)
          Set the validity interval for the wrapped value.
protected abstract  void setValue(V value)
          Set the wrapped value, possibly null.
 java.lang.String toString()
           
 
Methods inherited from class com.anasoft.os.daofusion.entity.MutablePersistentEntity
clone, getVersion, setVersion
 
Methods inherited from class com.anasoft.os.daofusion.entity.PersistentEntity
getId, setId
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.anasoft.os.daofusion.bitemporal.Bitemporal
copyWith
 

Field Detail

_VALID_FROM

public static final java.lang.String _VALID_FROM
See Also:
Constant Field Values

_VALID_TO

public static final java.lang.String _VALID_TO
See Also:
Constant Field Values

_RECORD_FROM

public static final java.lang.String _RECORD_FROM
See Also:
Constant Field Values

_RECORD_TO

public static final java.lang.String _RECORD_TO
See Also:
Constant Field Values
Constructor Detail

BitemporalWrapper

protected BitemporalWrapper()

BitemporalWrapper

public BitemporalWrapper(V value,
                         org.joda.time.Interval validityInterval)
Bitemporally wrap the given value. Validity will be as specified, and the recording interval will be from now on.

Parameters:
value - The value to wrap (can be null).
validityInterval - Validity of the value.
Method Detail

setValue

protected abstract void setValue(V value)
Set the wrapped value, possibly null.


getValue

public abstract V getValue()
Returns the wrapped value, possibly null.


getValidityInterval

public org.joda.time.Interval getValidityInterval()
Description copied from interface: Bitemporal
Returns the interval in which this bitemporal object is valid.

Specified by:
getValidityInterval in interface Bitemporal
See Also:
Bitemporal.getValidityInterval()

setValidityInterval

protected void setValidityInterval(org.joda.time.Interval validityInterval)
Set the validity interval for the wrapped value.


getRecordInterval

public org.joda.time.Interval getRecordInterval()
Description copied from interface: Bitemporal
Returns the interval in which this bitemporal object is known.

Specified by:
getRecordInterval in interface Bitemporal
See Also:
Bitemporal.getRecordInterval()

end

public void end()
Description copied from interface: Bitemporal
End the recording interval of this bitemporal object, indicating that it has been superseded by a new object, or is deemed as no longer relevant (i.e. because it was faulty knowledge) and should be "forgotten".

Specified by:
end in interface Bitemporal
See Also:
Bitemporal.end()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2008-2009 ANASOFT and contributors. All Rights Reserved.