org.starhope.appius.util
Class SimpleDataRecord<T extends SimpleDataRecord<?>>

java.lang.Object
  extended by org.starhope.appius.util.SimpleDataRecord<T>
Type Parameters:
T - The specific subclass type is required to declare itself to bypass some very strange Java generic class issues
All Implemented Interfaces:
com.whirlycott.cache.Cacheable, Serializable, Comparable<T>, CTime, DataRecord, HasSubversionRevision
Direct Known Subclasses:
AvatarBodyFormat, AvatarClass, CapabilityRecords, Currency, Enrolment, EventOutcomeRecord, EventRecord, EventType, GenericItemReference, InventoryItem, InventoryItemType, ItemCollection, ItemEffectsType, MailAddressRecord, MedalRecord, Notification, Parent, Passport, Persephone2AppConfig, PersonRecord, RarityRating, Room, RoomLayer, SimpleDataEnum, SimpleDataRecordSet, SimpleUserListEntry, StringRecord, UserEnrolment, UserHouse, UserItemCollection, UserPreferenceRecord, UserRecord, UserStat, Wallet, ZoneServerRecord

public abstract class SimpleDataRecord<T extends SimpleDataRecord<?>>
extends Object
implements DataRecord, Comparable<T>, Serializable

An abstract implementation of a DataRecord performing the default tasks for most of the drudgery.

Author:
brpocock@star-hope.org
See Also:
Serialized Form

Field Summary
private  boolean beenCached
          Whether this object has been cached
private  boolean beingLoaded
          WRITEME: Document this brpocock@star-hope.org
protected  RecordLoader<T> myLoader
          WRITEME: Document this brpocock@star-hope.org
private static long serialVersionUID
          Java serialisation unique ID
protected  long timeLastChanged
          WRITEME
protected  long timeLastSaved
          WRITEME
 
Constructor Summary
protected SimpleDataRecord(Class<? extends SimpleDataRecord<T>> klass)
          Protected constructor for derived classes to use, creating a new record using the default loader configured for that class
  SimpleDataRecord(RecordLoader<? super T> loader)
           
 
Method Summary
protected  void changed()
          WRITEME: Document this method brpocock@star-hope.org
 void checkStale()
          Indicates that a data record is stale and needs to be refreshed
 int compareTo(T o)
           
 boolean equals(Object obj)
           
protected  void finalize()
           
 RecordLoader<? super T> getRecordLoader()
           
 long getTimeLastChanged()
           
 long getTimeLastSaved()
           
 int hashCode()
           
 boolean isBeingLoaded()
          WRITEME: Document this method brpocock@star-hope.org
 void markAsLoaded()
          WRITEME: Document this method brpocock@star-hope.org
 void markAsSaved()
          Record the current time as the time last saved
 void markForReload()
          Marks a record as
 void onRemove(Object value)
           
 void onRetrieve(Object value)
           
 void onStore(Object value)
           
protected  void save()
          Saves the record immediately instead of waiting
 void setRecordLoader(RecordLoader<? extends DataRecord> loader)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.starhope.appius.util.DataRecord
getCacheableID, getCacheableIdent
 
Methods inherited from interface org.starhope.util.HasSubversionRevision
getSubversionRevision
 

Field Detail

serialVersionUID

private static final long serialVersionUID
Java serialisation unique ID

See Also:
Constant Field Values

beenCached

private boolean beenCached
Whether this object has been cached


beingLoaded

private boolean beingLoaded
WRITEME: Document this brpocock@star-hope.org


myLoader

protected transient RecordLoader<T extends SimpleDataRecord<?>> myLoader
WRITEME: Document this brpocock@star-hope.org


timeLastChanged

protected long timeLastChanged
WRITEME


timeLastSaved

protected long timeLastSaved
WRITEME

Constructor Detail

SimpleDataRecord

protected SimpleDataRecord(Class<? extends SimpleDataRecord<T>> klass)
Protected constructor for derived classes to use, creating a new record using the default loader configured for that class

Parameters:
klass - the derived class

SimpleDataRecord

public SimpleDataRecord(RecordLoader<? super T> loader)
Parameters:
loader - the record loader in use
Method Detail

changed

protected void changed()
WRITEME: Document this method brpocock@star-hope.org


checkStale

public void checkStale()
Description copied from interface: DataRecord
Indicates that a data record is stale and needs to be refreshed

Specified by:
checkStale in interface DataRecord
See Also:
checkStale()

compareTo

public int compareTo(T o)
Specified by:
compareTo in interface Comparable<T extends SimpleDataRecord<?>>
See Also:
Comparable.compareTo(java.lang.Object)

equals

public boolean equals(Object obj)
Overrides:
equals in class Object
See Also:
Object.equals(java.lang.Object)

finalize

protected void finalize()
Overrides:
finalize in class Object
See Also:
Object.finalize()

getRecordLoader

public RecordLoader<? super T> getRecordLoader()
Specified by:
getRecordLoader in interface DataRecord
Returns:
The record loader used to instantiate (and save) this data record
See Also:
DataRecord.getRecordLoader()

getTimeLastChanged

public final long getTimeLastChanged()
Specified by:
getTimeLastChanged in interface CTime
Returns:
The time since epoch at which this object last changed, where “-1” indicates that it has never been changed.
See Also:
CTime.getTimeLastChanged()

getTimeLastSaved

public final long getTimeLastSaved()
Specified by:
getTimeLastSaved in interface CTime
Returns:
The time since epoch at which this object was last saved to its backing store, where “-1” indicates that it has never been written to a backing store.
See Also:
CTime.getTimeLastSaved()

hashCode

public int hashCode()
Overrides:
hashCode in class Object
See Also:
Object.hashCode()

isBeingLoaded

public boolean isBeingLoaded()
Description copied from interface: DataRecord
WRITEME: Document this method brpocock@star-hope.org

Specified by:
isBeingLoaded in interface DataRecord
Returns:
WRITEME
See Also:
DataRecord.isBeingLoaded()

markAsLoaded

public void markAsLoaded()
Description copied from interface: DataRecord
WRITEME: Document this method brpocock@star-hope.org

Specified by:
markAsLoaded in interface DataRecord
See Also:
DataRecord.markAsLoaded()

markForReload

public void markForReload()
Marks a record as


markAsSaved

public final void markAsSaved()
Description copied from interface: DataRecord
Record the current time as the time last saved

Specified by:
markAsSaved in interface DataRecord
See Also:
DataRecord.markAsSaved()

onRemove

public void onRemove(Object value)
Specified by:
onRemove in interface com.whirlycott.cache.Cacheable
See Also:
Cacheable.onRemove(java.lang.Object)

onRetrieve

public void onRetrieve(Object value)
Specified by:
onRetrieve in interface com.whirlycott.cache.Cacheable
See Also:
Cacheable.onRetrieve(java.lang.Object)

onStore

public void onStore(Object value)
Specified by:
onStore in interface com.whirlycott.cache.Cacheable
See Also:
Cacheable.onStore(java.lang.Object)

save

protected void save()
Saves the record immediately instead of waiting


setRecordLoader

public final void setRecordLoader(RecordLoader<? extends DataRecord> loader)
Specified by:
setRecordLoader in interface DataRecord
Parameters:
loader - The record loader that should be used to save this data record
See Also:
DataRecord.setRecordLoader(org.starhope.appius.util.RecordLoader)

toString

public String toString()
Overrides:
toString in class Object
See Also:
Object.toString()