org.starhope.appius.user
Class UserHouse

java.lang.Object
  extended by org.starhope.appius.util.SimpleDataRecord<UserHouse>
      extended by org.starhope.appius.user.UserHouse
All Implemented Interfaces:
com.whirlycott.cache.Cacheable, Serializable, Comparable<UserHouse>, Map<Integer,Room>, CTime, DataRecord, HasSubversionRevision

public class UserHouse
extends SimpleDataRecord<UserHouse>
implements Map<Integer,Room>

The User House object contains the rooms of the user's own house. Each user gets only one house, although we could maybe do some scary linkage things where rooms are discontinuous. There is a hard-coded assertion that room 0 is the main, lobby, entrance room of the user's house, and room 1 is the external front yard.

 CREATE TABLE userHouseRooms (userID INT NOT NULL, roomID DECIMAL(1,0) UNSIGNED NOT NULL, PRIMARY KEY (userID, roomID), CONSTRAINT FOREIGN KEY (userID) REFERENCES users (ID)) ENGINE=InnoDB;
 

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

Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Field Summary
private  ConcurrentHashMap<Integer,Boolean> hasRooms
          Whether a room has been instantiated or not
private  ConcurrentHashMap<Integer,Room> houseRooms
          The internal representation of the set of Rooms in the user's house
private  int houseTypeID
          The view of the house from outside is hacked in like this for now XXX
private  int lotID
          The type of lot for the outside is hacked in like this for now XXX
private  AbstractUser owner
          The owner of this house
private static long serialVersionUID
          WRITEME: Document this brpocock@star-hope.org
 
Fields inherited from class org.starhope.appius.util.SimpleDataRecord
myLoader, timeLastChanged, timeLastSaved
 
Constructor Summary
UserHouse(AbstractUser newOwner)
          Instantiate the house of the given user
 
Method Summary
 void addRoom(int id)
          WRITEME
private  void addRooms(Integer[] integers)
          Add rooms of the given numbers for the owner
 void clear()
          This is an overriding method.
 boolean containsKey(Object key)
          This is an overriding method.
 boolean containsValue(Object value)
          This is an overriding method.
 Set<Map.Entry<Integer,Room>> entrySet()
          This is an overriding method.
 Room get(Object key)
          This is an overriding method.
 int getCacheableID()
          Note that all records must have either a numeric ID ( DataRecord.getCacheableID() or a string identifier ( DataRecord.getCacheableIdent() or both.
 String getCacheableIdent()
          Note that all records must have either a numeric ID ( DataRecord.getCacheableID() or a string identifier ( DataRecord.getCacheableIdent() or both.
 int getHouseTypeID()
           
 int getLotID()
          WRITEME: document this method (brpocock@star-hope.org, Feb 19, 2010)
 AbstractUser getOwner()
           
 String getSubversionRevision()
           Return the Subversion revision level of this class's source code file, as supplied via the special "$Rev: " sequence.
private  void instantiateRoom(Integer key)
          instantiate the given room if it's called-for
 boolean isEmpty()
          This is an overriding method.
 Set<Integer> keySet()
          This is an overriding method.
 Room put(Integer key, Room value)
          This is an overriding method.
 void putAll(Map<? extends Integer,? extends Room> m)
          This is an overriding method.
 Room remove(Object key)
          This is an overriding method.
 void setHouseTypeID(int houseTypeID1)
          WRITEME: document this method (brpocock@star-hope.org, Feb 19, 2010)
 void setLotID(int lotID1)
          WRITEME: document this method (brpocock@star-hope.org, Feb 19, 2010)
 int size()
          This is an overriding method.
 Collection<Room> values()
          This is an overriding method.
 
Methods inherited from class org.starhope.appius.util.SimpleDataRecord
changed, checkStale, compareTo, equals, finalize, getRecordLoader, getTimeLastChanged, getTimeLastSaved, hashCode, isBeingLoaded, markAsLoaded, markAsSaved, markForReload, onRemove, onRetrieve, onStore, save, setRecordLoader, toString
 
Methods inherited from class java.lang.Object
clone, equals, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Field Detail

serialVersionUID

private static final long serialVersionUID
WRITEME: Document this brpocock@star-hope.org

See Also:
Constant Field Values

houseRooms

private final ConcurrentHashMap<Integer,Room> houseRooms
The internal representation of the set of Rooms in the user's house


hasRooms

private final ConcurrentHashMap<Integer,Boolean> hasRooms
Whether a room has been instantiated or not


houseTypeID

private int houseTypeID
The view of the house from outside is hacked in like this for now XXX


lotID

private int lotID
The type of lot for the outside is hacked in like this for now XXX


owner

private final AbstractUser owner
The owner of this house

Constructor Detail

UserHouse

public UserHouse(AbstractUser newOwner)
Instantiate the house of the given user

Parameters:
newOwner - the owner of the house
Method Detail

addRoom

public void addRoom(int id)
WRITEME

Parameters:
id - index

addRooms

private void addRooms(Integer[] integers)
Add rooms of the given numbers for the owner

Parameters:
integers - the room numbers

clear

public void clear()
This is an overriding method.

Specified by:
clear in interface Map<Integer,Room>
See Also:
Map.clear()

containsKey

public boolean containsKey(Object key)
This is an overriding method.

Specified by:
containsKey in interface Map<Integer,Room>
See Also:
Map.containsKey(java.lang.Object)

containsValue

public boolean containsValue(Object value)
This is an overriding method.

Specified by:
containsValue in interface Map<Integer,Room>
See Also:
Map.containsValue(java.lang.Object)

entrySet

public Set<Map.Entry<Integer,Room>> entrySet()
This is an overriding method.

Specified by:
entrySet in interface Map<Integer,Room>
See Also:
Map.entrySet()

get

public Room get(Object key)
This is an overriding method.

Specified by:
get in interface Map<Integer,Room>
See Also:
Map.get(java.lang.Object)

getCacheableID

public int getCacheableID()
                   throws NotFoundException
Description copied from interface: DataRecord
Note that all records must have either a numeric ID ( DataRecord.getCacheableID() or a string identifier ( DataRecord.getCacheableIdent() or both.

Specified by:
getCacheableID in interface DataRecord
Returns:
an unique ID number
Throws:
NotFoundException - if the item doesn't have a distinct numeric ID
See Also:
DataRecord.getCacheableID()

getCacheableIdent

public String getCacheableIdent()
Description copied from interface: DataRecord
Note that all records must have either a numeric ID ( DataRecord.getCacheableID() or a string identifier ( DataRecord.getCacheableIdent() or both.

Specified by:
getCacheableIdent in interface DataRecord
Returns:
an unique identifier string
See Also:
DataRecord.getCacheableIdent()

getHouseTypeID

public int getHouseTypeID()
Returns:
the houseType

getLotID

public int getLotID()
WRITEME: document this method (brpocock@star-hope.org, Feb 19, 2010)

Returns:
WRITEME

getOwner

public AbstractUser getOwner()
Returns:
the owner

getSubversionRevision

public String getSubversionRevision()
Description copied from interface: HasSubversionRevision

Return the Subversion revision level of this class's source code file, as supplied via the special "$Rev: " sequence.

As an example,the Subversion revision string for this file is "$Rev: 1968 $"

 
 @Override
 public String getSubversionRevision () {
        return "$Rev: ";
 }
 

Specified by:
getSubversionRevision in interface HasSubversionRevision
Returns:
The Subversion revision level for this class's source code file.
See Also:
HasSubversionRevision.getSubversionRevision()

instantiateRoom

private void instantiateRoom(Integer key)
instantiate the given room if it's called-for

Parameters:
key - room number

isEmpty

public boolean isEmpty()
This is an overriding method.

Specified by:
isEmpty in interface Map<Integer,Room>
See Also:
Map.isEmpty()

keySet

public Set<Integer> keySet()
This is an overriding method.

Specified by:
keySet in interface Map<Integer,Room>
See Also:
Map.keySet()

put

public Room put(Integer key,
                Room value)
This is an overriding method.

Specified by:
put in interface Map<Integer,Room>
See Also:
Map.put(java.lang.Object, java.lang.Object)

putAll

public void putAll(Map<? extends Integer,? extends Room> m)
This is an overriding method.

Specified by:
putAll in interface Map<Integer,Room>
See Also:
Map.putAll(java.util.Map)

remove

public Room remove(Object key)
This is an overriding method.

Specified by:
remove in interface Map<Integer,Room>
See Also:
Map.remove(java.lang.Object)

setHouseTypeID

public void setHouseTypeID(int houseTypeID1)
WRITEME: document this method (brpocock@star-hope.org, Feb 19, 2010)

Parameters:
houseTypeID1 - WRITEME

setLotID

public void setLotID(int lotID1)
WRITEME: document this method (brpocock@star-hope.org, Feb 19, 2010)

Parameters:
lotID1 - WRITEME

size

public int size()
This is an overriding method.

Specified by:
size in interface Map<Integer,Room>
See Also:
Map.size()

values

public Collection<Room> values()
This is an overriding method.

Specified by:
values in interface Map<Integer,Room>
See Also:
Map.values()