org.deduced
Class IdPropertyMap<V>

java.lang.Object
  extended by org.deduced.AbstractPropertyCollection<K,V>
      extended by org.deduced.PropertyMap<java.lang.Object,V>
          extended by org.deduced.IdPropertyMap<V>
Type Parameters:
V - the type of value in the map
All Implemented Interfaces:
java.lang.Cloneable, PropertyCollection<java.lang.Object,V>
Direct Known Subclasses:
PropertyList

public class IdPropertyMap<V>
extends PropertyMap<java.lang.Object,V>

IdPropertyMap. This class has 2 different behaviors. If the instance is by reference, keys are automatically assigned with an incremental counter. If keys are held by value, the property collection use their system unique ID as a key. This implies that this collection may not receive multiple times the same value instance.

Author:
Steve McDuff

Nested Class Summary
 
Nested classes/interfaces inherited from class org.deduced.PropertyMap
PropertyMap.PropertyIterator, PropertyMap.ValueIterator
 
Nested classes/interfaces inherited from class org.deduced.AbstractPropertyCollection
AbstractPropertyCollection.CollectionToDeleteMonitor
 
Field Summary
private  int nextKey
          integer used to generate keys when the list contains references
private static long serialVersionUID
          the serial version
 
Fields inherited from class org.deduced.PropertyMap
PROPERTY_MAP_TYPE
 
Fields inherited from class org.deduced.AbstractPropertyCollection
CHECK_DELETE_MODE_AUTOMATIC, CHECK_DELETE_MODE_MANUAL, COLLECTION_TO_DELETE
 
Fields inherited from interface org.deduced.PropertyCollection
PROPERTY_COLLECTION_TYPE
 
Constructor Summary
IdPropertyMap()
          default constructor
IdPropertyMap(java.util.Map<java.lang.Object,Property<V>> mapToUse, PropertyCollection<?,?> setFixedInstance)
          constructor for IdPropertyMap
IdPropertyMap(PropertyCollection<?,?> setFixedInstance)
          constructor for IdPropertyMap
 
Method Summary
 java.lang.Object addProperty(java.lang.Object key, PropertyCollection<?,?> instance, V value)
          (non-Javadoc)
 boolean areKeysAssignedAutomatically()
          (non-Javadoc)
protected  java.lang.IllegalArgumentException createThrowMustNotSpecifyKeyError()
          method to throw the error generated when a key is specified during addition while IdPropertyMap doesn't allow this.
 boolean equals(java.lang.Object obj)
          (non-Javadoc)
protected  java.lang.Object generateKey(java.lang.Object value)
          generate a key for a newly inserted object
 int hashCode()
          (non-Javadoc)
 java.lang.Object instanceKey(java.lang.Object instance)
          (non-Javadoc)
private  boolean isBaseInformationEqual(PropertyCollection<?,?> otherMap)
          check if the base map information is equal such as type, size and fixed instance.
private  boolean isMapContentEqual(PropertyCollection<?,?> otherMap)
          is the map content equal by verifying objects one by one.
 Property<V> removePropertyInstance(V instance)
          (non-Javadoc)
 
Methods inherited from class org.deduced.PropertyMap
asKeySet, cleanNewlyClonedValue, clone, containsKey, getFixedInstance, getProperty, getPropertyValue, handleRemovedProperty, internalAddProperty, internalIsSetValueParentNecessary, internalRemoveProperty, internalSetValueParentIfNecessary, isFixedInstanceReference, iterator, iteratorByValue, putPropertyInMap, removeProperty, removePropertyValue, resetRemovedPropertyParent, setFixedInstance, setProperty, size, type, validateCollectionParentBeforeAddition
 
Methods inherited from class org.deduced.AbstractPropertyCollection
activate, addListener, asPropertyList, asPropertyMap, asValueList, asValueMap, callObjectClone, classLogger, clear, clearCollectionMonitoredForDelete, cloneCollection, containsInstance, containsValue, createUniqueID, delete, deleteClearAllProperties, deleteClearListenerList, deleteFireDeleteEvent, deleteProcessCompletedValidation, deleteRemoveLocalObjectFromParent, deleteValidateEmptyListenerList, deleteValidateNoPendingReferences, firePropertyChangeEvent, flushCollectionsWithNewParent, flushCollectionsWithNewParent, getActionInvoker, getCheckDeleteMode, getCheckDeleteRunner, getInstanceIdentityKey, id, internalFirePropertyChangeEvent, invokeAction, isActivated, isDeleteCheckedOnClearParent, isEmpty, isListenerRegistered, isParentOrKeyNull, keyOnParent, parent, removeListener, requiresChangeEvent, setActionInvoker, setCheckDeleteMode, setCheckDeleteRunner, setDeleteCheckedOnClearParent, setParent, toString, updateReference, updateReferenceWithReferenceFlag, validateAllPropertyInstances, validateNoListener, validateNoParentRecursion, validateParentIsNull, validateParentIsNull, valueKey
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
the serial version

See Also:
Constant Field Values

nextKey

private int nextKey
integer used to generate keys when the list contains references

Constructor Detail

IdPropertyMap

public IdPropertyMap()
default constructor


IdPropertyMap

public IdPropertyMap(java.util.Map<java.lang.Object,Property<V>> mapToUse,
                     PropertyCollection<?,?> setFixedInstance)
constructor for IdPropertyMap

Parameters:
mapToUse - the map to use to store the values
setFixedInstance - the fixed instance contained in this collection

IdPropertyMap

public IdPropertyMap(PropertyCollection<?,?> setFixedInstance)
constructor for IdPropertyMap

Parameters:
setFixedInstance - the fixed instance contained in this collection
Method Detail

createThrowMustNotSpecifyKeyError

protected java.lang.IllegalArgumentException createThrowMustNotSpecifyKeyError()
method to throw the error generated when a key is specified during addition while IdPropertyMap doesn't allow this.

Returns:
the created exception

addProperty

public java.lang.Object addProperty(java.lang.Object key,
                                    PropertyCollection<?,?> instance,
                                    V value)
(non-Javadoc)

Specified by:
addProperty in interface PropertyCollection<java.lang.Object,V>
Overrides:
addProperty in class PropertyMap<java.lang.Object,V>
Parameters:
key - the key of the property. Some collections assign keys automatically, for those collections, a null value is expected. If the key is specified when they are assigned automatically, an IllegalArgumentException will be thrown
instance - the property instance to add. Most collections assign the instance automatically, for those collections, the instance can either be null or be the same as the instance that is automatically assigned, otherwise an error will be thrown
value - the property value. If the value is a property collection, then the collection is expected to have a null parent if the instance is owned (not by reference), otherwise an IllegalArgumentException will be thrown
Returns:
the added property key
See Also:
PropertyMap.addProperty(java.lang.Object, org.deduced.PropertyCollection, java.lang.Object)

generateKey

protected java.lang.Object generateKey(java.lang.Object value)
generate a key for a newly inserted object

Parameters:
value - the value to insert
Returns:
the generated key

removePropertyInstance

public Property<V> removePropertyInstance(V instance)
(non-Javadoc)

Specified by:
removePropertyInstance in interface PropertyCollection<java.lang.Object,V>
Overrides:
removePropertyInstance in class PropertyMap<java.lang.Object,V>
Parameters:
instance - the object to remove
Returns:
the removed object
See Also:
PropertyCollection.removePropertyInstance(java.lang.Object)

instanceKey

public java.lang.Object instanceKey(java.lang.Object instance)
(non-Javadoc)

Specified by:
instanceKey in interface PropertyCollection<java.lang.Object,V>
Overrides:
instanceKey in class AbstractPropertyCollection<java.lang.Object,V>
Parameters:
instance - the object instance
Returns:
the key of this instance
See Also:
PropertyCollection.instanceKey(java.lang.Object)

areKeysAssignedAutomatically

public boolean areKeysAssignedAutomatically()
(non-Javadoc)

Specified by:
areKeysAssignedAutomatically in interface PropertyCollection<java.lang.Object,V>
Overrides:
areKeysAssignedAutomatically in class PropertyMap<java.lang.Object,V>
Returns:
true if the keys are assigned automatically by the collection
See Also:
PropertyCollection.areKeysAssignedAutomatically()

equals

public boolean equals(java.lang.Object obj)
(non-Javadoc)

Overrides:
equals in class AbstractPropertyCollection<java.lang.Object,V>
See Also:
AbstractPropertyCollection.equals(java.lang.Object)

isBaseInformationEqual

private boolean isBaseInformationEqual(PropertyCollection<?,?> otherMap)
check if the base map information is equal such as type, size and fixed instance.

Parameters:
otherMap - the other map to verify
Returns:
true if the base information is equal, false otherwise.

isMapContentEqual

private boolean isMapContentEqual(PropertyCollection<?,?> otherMap)
is the map content equal by verifying objects one by one.

Parameters:
otherMap - the other map to verify
Returns:
true if the map content is equal

hashCode

public int hashCode()
(non-Javadoc)

Overrides:
hashCode in class AbstractPropertyCollection<java.lang.Object,V>
See Also:
AbstractPropertyCollection.hashCode()