|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.deduced.AbstractPropertyCollection<K,V>
org.deduced.PropertyMap<java.lang.Object,java.lang.Object>
org.deduced.dynamic.DynamicPropertyMap
public class DynamicPropertyMap
This class is used to create dynamic property collections that change as their defined type changes
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 boolean |
activated
is the collection active. |
private RuleExecutionContext |
context
rule execution context |
private static java.util.IdentityHashMap<PropertyType,java.lang.Object> |
DEFAULT_VALUES
map of the possible default values |
private static java.util.logging.Logger |
LOGGER
logger |
private java.util.Map<PropertyCollection<?,?>,DeducedProperty<java.lang.Object>> |
rulePropertyMap
map of all the rules implemented by the type and their properties |
private static long |
serialVersionUID
serial ID |
private PropertyCollection<?,?> |
type
type of the dynamic property map |
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 | |
---|---|
DynamicPropertyMap(PropertyCollection<?,?> setType,
boolean setActivated,
RuleExecutionContext setContext)
DynamicPropertyMap Constructor |
Method Summary | |
---|---|
void |
activate()
(non-Javadoc) |
protected void |
activateOwnedChildCollections()
activate all Owned Child Collections |
static void |
activateOwnedChildCollections(PropertyCollection<?,?> collectionToActivate)
activate all Owned Child Collections |
void |
addDeductionRule(PropertyCollection<?,?> rule)
add Deduction Rule |
private void |
applyAllDeductionRuleOverrides()
apply All Deduction Rule Overrides |
private void |
applyRuleMissingOverride(PropertyCollection<?,?> rule,
DeducedProperty<java.lang.Object> propertyOverride)
apply Rule Missing Override |
static java.lang.Object |
attemptToCreateValue(PropertyCollection<?,?> changedInstance,
RuleExecutionContext context,
PropertyCollection<?,?> collectionToInitialize)
attempt To Create Value |
protected void |
cleanNewlyClonedValue(AbstractPropertyCollection<java.lang.Object,java.lang.Object> newClone)
(non-JSDoc) |
java.lang.Object |
clone()
(non-Javadoc) |
private void |
createAllDeducedProperties()
create All Deduced Properties |
private void |
createAllDeducedProperties(PropertyCollection<?,?> activateType,
java.util.List<PropertyCollection<?,?>> activatedTypes)
create All Deduced Properties |
private DeducedProperty<java.lang.Object> |
createDeducedProperty(PropertyCollection deductionRule,
DeductionRuleAnalyzer<java.lang.Object> analyzer,
PropertyCollection<?,?> lastInstance)
create Deduced Property |
private void |
createDeductionRuleProperties(PropertyCollection<?,?> rebuildType)
create Deduction Rule Properties |
private void |
createDeductionRuleProperty(PropertyCollection deductionRule)
create Deduction Rule Property |
static java.lang.Object |
createObjectIfBasicType(PropertyCollection<?,?> type)
create Object If it is a Basic Type |
void |
delete()
(non-Javadoc) |
private void |
deleteAllDeductionRuleProperties()
delete All Deduction Rule Properties |
void |
deleteProperty(java.lang.Object key)
delete Property |
void |
deletePropertyInstance(PropertyCollection<?,?> changedInstance)
delete Property Instance |
private void |
disconnectCollectionFromPreviousParent(PropertyCollection<?,?> previousParent)
disconnect Collection From Previous Parent |
private static DeducedProperty<java.lang.Object> |
findMatchingRuleInMap(java.util.List<PropertyCollection<?,?>> reverseInstanceList,
PropertyCollection<?,?> ruleToAvoid,
DynamicPropertyMap map)
find a rule in a property map that matches the reverse instance list, overrides other rules and doesn't match one of the rules to avoid. |
private static DeducedProperty<java.lang.Object> |
findOverride(PropertyCollection<?,?> searchPoint,
PropertyCollection<?,?> instance,
java.util.List<PropertyCollection<?,?>> reverseInstanceList,
PropertyCollection<?,?> ruleToAvoid)
find a property Override based on the parent list |
private void |
firePropertyChangeEventIfNecessary(PropertyCollection<?,?> instance,
java.lang.Object key,
java.lang.Object oldValue,
java.lang.Object newValue)
fire Property Change Event If Necessary |
RuleExecutionContext |
getContext()
get the rule execution Context |
private PropertyCollection<?,?> |
getLastOutputInstance(PropertyCollection deductionRule)
get Last Output Instance |
static int |
getOutputDepth(DeducedProperty<?> property)
get Output Depth of a rule associated with a deduced property |
static java.util.Collection<PropertyCollection<?,?>> |
getRecursiveParentList(PropertyCollection<?,?> startParent)
get Recursive Parent List |
static java.lang.String |
getRuleName(DeducedProperty<?> deducedProperty)
get Rule Name |
DeducedProperty<java.lang.Object> |
getRuleProperty(PropertyCollection deductionRule)
get Rule Property |
static java.lang.String |
getTypeName(PropertyCollection<?,?> collection)
get Type Name |
protected java.lang.Object |
internalAddProperty(java.lang.Object propertyKey,
Property<java.lang.Object> resultAdd)
(non-Javadoc) |
boolean |
isActivated()
(non-Javadoc) |
private static boolean |
isFirstPropertyOverridingSecondProperty(DynamicPropertyMap collectionToOverride,
DeducedProperty<java.lang.Object> firstProperty,
DeducedProperty<?> secondProperty)
test if a deduced property overrides another one by first testing the output depth. |
static boolean |
isRuleApplicableToChild(PropertyCollection<?,?> ruleInstanceList,
java.util.List<PropertyCollection<?,?>> instanceListToChild)
check if a Rule is Applicable To Child |
boolean |
isRulePropertyCreated(PropertyCollection deductionRule)
test if a Rule Property is Created |
private void |
overridePropertiesOnChild(java.util.List<PropertyCollection<?,?>> instanceListToChild)
override Properties On Child based on the list of deduction rule this collection has. |
private static void |
overridePropertyWithRule(DynamicPropertyMap collectionToOverride,
java.lang.Object key,
DeducedProperty<java.lang.Object> property)
override Property With Rule |
private void |
putRuleInRulePropertyMap(DeducedProperty<java.lang.Object> createdProperty)
put Rule In Rule Property Map |
private static void |
rebuildChildrenOverridesFromPreviousParents(java.util.Collection<PropertyCollection<?,?>> parentList,
PropertyCollection<?,?> currentChild)
this method is used to remove any deduced property on a collection that was created from a parent collection. |
void |
rebuildProperties()
rebuild Properties |
private void |
rebuildProperties(PropertyCollection<?,?> rebuildType,
java.util.List<PropertyCollection<?,?>> rebuiltTypes)
rebuild Properties of a specific type recursively |
void |
rebuildProperty(PropertyCollection<?,?> changedInstance)
rebuild Property |
private static void |
rebuildPropertyOverride(DynamicPropertyMap childCollection,
DeducedProperty<?> property,
PropertyCollection<?,?> ruleToAvoid)
rebuild Property Override |
void |
recursivelyOverrideChildProperties(PropertyCollection<?,?> instance)
recursively Override Child Properties based on the current parent of the collection |
void |
removeDeductionRule(PropertyCollection<?,?> rule)
remove Deduction Rule |
Property<java.lang.Object> |
removeProperty(java.lang.Object propertyKey)
(non-Javadoc) |
Property<java.lang.Object> |
removePropertyInstance(java.lang.Object instance)
(non-Javadoc) |
private void |
removeRuleOverrides(PropertyCollection<?,?> rule,
DeducedProperty<java.lang.Object> propertyOverride)
remove Rule Overrides |
static boolean |
ruleOutputMatchesReverseInstanceList(PropertyCollection<?,?> rule,
java.util.List<PropertyCollection<?,?>> reverseInstanceList)
verify if a rule Output Matches Reverse Instance List |
void |
setParent(PropertyCollection<?,?> parent,
java.lang.Object keyOnParent)
(non-Javadoc) |
private static boolean |
setParentOnNewValue(DynamicPropertyMap collectionToOverride,
java.lang.Object key,
DeducedProperty<java.lang.Object> property,
java.lang.Object newValue)
set Parent On New Value |
java.lang.Object |
setProperty(java.lang.Object propertyKey,
java.lang.Object value)
(non-Javadoc) |
PropertyCollection<?,?> |
type()
(non-Javadoc) |
protected boolean |
wasThePropertyReference(java.lang.Object propertyKey,
java.lang.Object oldValue,
boolean isReference)
test if the old property value was a reference |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.deduced.PropertyCollection |
---|
addListener, addProperty, areKeysAssignedAutomatically, asKeySet, asPropertyList, asPropertyMap, asValueList, asValueMap, clear, containsInstance, containsKey, containsValue, getFixedInstance, getProperty, getPropertyValue, id, instanceKey, invokeAction, isEmpty, isListenerRegistered, iterator, iteratorByValue, keyOnParent, parent, removeListener, removePropertyValue, setFixedInstance, size, valueKey |
Field Detail |
---|
private static final long serialVersionUID
private static final java.util.logging.Logger LOGGER
private PropertyCollection<?,?> type
private java.util.Map<PropertyCollection<?,?>,DeducedProperty<java.lang.Object>> rulePropertyMap
private boolean activated
private RuleExecutionContext context
private static final java.util.IdentityHashMap<PropertyType,java.lang.Object> DEFAULT_VALUES
Constructor Detail |
---|
public DynamicPropertyMap(PropertyCollection<?,?> setType, boolean setActivated, RuleExecutionContext setContext)
setType
- type of the collectionsetActivated
- is the collection activatedsetContext
- rule execution contextMethod Detail |
---|
public RuleExecutionContext getContext()
getContext
in interface ContextualPropertyCollection<java.lang.Object,java.lang.Object>
public boolean isActivated()
isActivated
in interface PropertyCollection<java.lang.Object,java.lang.Object>
isActivated
in class AbstractPropertyCollection<java.lang.Object,java.lang.Object>
AbstractPropertyCollection.isActivated()
public void activate()
activate
in interface PropertyCollection<java.lang.Object,java.lang.Object>
activate
in class AbstractPropertyCollection<java.lang.Object,java.lang.Object>
AbstractPropertyCollection.activate()
protected void activateOwnedChildCollections()
public static void activateOwnedChildCollections(PropertyCollection<?,?> collectionToActivate)
collectionToActivate
- the collection to activateprivate void applyAllDeductionRuleOverrides()
private void createAllDeducedProperties()
public void rebuildProperties()
private void createAllDeducedProperties(PropertyCollection<?,?> activateType, java.util.List<PropertyCollection<?,?>> activatedTypes)
activateType
- type to create all the deduced properties fromactivatedTypes
- list of types that have already been parsedprivate void rebuildProperties(PropertyCollection<?,?> rebuildType, java.util.List<PropertyCollection<?,?>> rebuiltTypes)
rebuildType
- type to rebuild all the propertiesrebuiltTypes
- list of all the types that have already been rebuiltprivate void createDeductionRuleProperties(PropertyCollection<?,?> rebuildType)
rebuildType
- the type to rebuild the rules fromprivate void createDeductionRuleProperty(PropertyCollection deductionRule)
deductionRule
- deduction rule model from which to create the
property onprivate PropertyCollection<?,?> getLastOutputInstance(PropertyCollection deductionRule)
deductionRule
- the deduction rule from which to fetch the last
output instance
public boolean isRulePropertyCreated(PropertyCollection deductionRule)
deductionRule
- the deduction rule to check
public DeducedProperty<java.lang.Object> getRuleProperty(PropertyCollection deductionRule)
deductionRule
- the deduction rule
private void putRuleInRulePropertyMap(DeducedProperty<java.lang.Object> createdProperty)
createdProperty
- the deduced property to put in the rule mapprivate DeducedProperty<java.lang.Object> createDeducedProperty(PropertyCollection deductionRule, DeductionRuleAnalyzer<java.lang.Object> analyzer, PropertyCollection<?,?> lastInstance) throws java.lang.Exception
deductionRule
- the deduction rule used to create the propertyanalyzer
- the analyzer used for the propertylastInstance
- the last instance in the rule output
java.lang.Exception
- any exception detected while executing the ruleprivate static void overridePropertyWithRule(DynamicPropertyMap collectionToOverride, java.lang.Object key, DeducedProperty<java.lang.Object> property)
collectionToOverride
- the collection to overridekey
- the key of the property to overrideproperty
- the property to use during the overrideprivate static boolean setParentOnNewValue(DynamicPropertyMap collectionToOverride, java.lang.Object key, DeducedProperty<java.lang.Object> property, java.lang.Object newValue)
collectionToOverride
- the parent of the new valuekey
- the key of the new value on the parentproperty
- the property used to overridenewValue
- the new value on which we set the parent
private static boolean isFirstPropertyOverridingSecondProperty(DynamicPropertyMap collectionToOverride, DeducedProperty<java.lang.Object> firstProperty, DeducedProperty<?> secondProperty)
collectionToOverride
- the collection to overridefirstProperty
- the first deduced propertysecondProperty
- the second property to compare to the first
public static java.lang.String getRuleName(DeducedProperty<?> deducedProperty)
deducedProperty
- the deduced property from which to fetch the rule
name
public static java.lang.String getTypeName(PropertyCollection<?,?> collection)
collection
- the collection from which to fetch the type name
public static int getOutputDepth(DeducedProperty<?> property)
property
- the deduced property
private void firePropertyChangeEventIfNecessary(PropertyCollection<?,?> instance, java.lang.Object key, java.lang.Object oldValue, java.lang.Object newValue)
instance
- the instance that changedkey
- the key that changedoldValue
- the old valuenewValue
- the new valuepublic void setParent(PropertyCollection<?,?> parent, java.lang.Object keyOnParent)
setParent
in interface PropertyCollection<java.lang.Object,java.lang.Object>
setParent
in class AbstractPropertyCollection<java.lang.Object,java.lang.Object>
parent
- The parent to set.keyOnParent
- the key on the parent to reference this objectAbstractPropertyCollection.setParent(org.deduced.PropertyCollection,
java.lang.Object)
private void disconnectCollectionFromPreviousParent(PropertyCollection<?,?> previousParent)
previousParent
- the previous parent to disconnect fromprivate static void rebuildChildrenOverridesFromPreviousParents(java.util.Collection<PropertyCollection<?,?>> parentList, PropertyCollection<?,?> currentChild)
parentList
- list of parents that are no longer a parent to this
collection.currentChild
- child which will see all the properties that were
overridden by its parent rebuilt.private static void rebuildPropertyOverride(DynamicPropertyMap childCollection, DeducedProperty<?> property, PropertyCollection<?,?> ruleToAvoid)
childCollection
- the child collection that contains the property to
rebuildproperty
- the previous propertyruleToAvoid
- the rules to avoidprivate static DeducedProperty<java.lang.Object> findOverride(PropertyCollection<?,?> searchPoint, PropertyCollection<?,?> instance, java.util.List<PropertyCollection<?,?>> reverseInstanceList, PropertyCollection<?,?> ruleToAvoid)
searchPoint
- the collection where to begin the searchinstance
- the instance that might need an overridereverseInstanceList
- the list of instances leading to this objectruleToAvoid
- the rules to avoid
private static DeducedProperty<java.lang.Object> findMatchingRuleInMap(java.util.List<PropertyCollection<?,?>> reverseInstanceList, PropertyCollection<?,?> ruleToAvoid, DynamicPropertyMap map)
reverseInstanceList
- the reverse instance list of the ruleruleToAvoid
- the rules to avoidmap
- the map on which to search
public static boolean ruleOutputMatchesReverseInstanceList(PropertyCollection<?,?> rule, java.util.List<PropertyCollection<?,?>> reverseInstanceList)
rule
- the rule to matchreverseInstanceList
- the reverse instance list
public static java.util.Collection<PropertyCollection<?,?>> getRecursiveParentList(PropertyCollection<?,?> startParent)
startParent
- the start collection to get all the parents from. This
parent will be included in the returned list.
public void deletePropertyInstance(PropertyCollection<?,?> changedInstance)
changedInstance
- the instance that was removedpublic void deleteProperty(java.lang.Object key)
key
- the property key to deletepublic void rebuildProperty(PropertyCollection<?,?> changedInstance)
changedInstance
- the instance that changedpublic Property<java.lang.Object> removeProperty(java.lang.Object propertyKey)
removeProperty
in interface PropertyCollection<java.lang.Object,java.lang.Object>
removeProperty
in class PropertyMap<java.lang.Object,java.lang.Object>
propertyKey
- the key of the property
PropertyMap.removeProperty(java.lang.Object)
public Property<java.lang.Object> removePropertyInstance(java.lang.Object instance)
removePropertyInstance
in interface PropertyCollection<java.lang.Object,java.lang.Object>
removePropertyInstance
in class PropertyMap<java.lang.Object,java.lang.Object>
instance
- the object to remove
PropertyMap.removePropertyInstance(java.lang.Object)
public static java.lang.Object attemptToCreateValue(PropertyCollection<?,?> changedInstance, RuleExecutionContext context, PropertyCollection<?,?> collectionToInitialize)
changedInstance
- the value that changedcontext
- the rule execution context used to create child valuescollectionToInitialize
- the collection to initialize
public static java.lang.Object createObjectIfBasicType(PropertyCollection<?,?> type)
type
- the type to create
public PropertyCollection<?,?> type()
type
in interface PropertyCollection<java.lang.Object,java.lang.Object>
type
in class PropertyMap<java.lang.Object,java.lang.Object>
PropertyMap.type()
protected java.lang.Object internalAddProperty(java.lang.Object propertyKey, Property<java.lang.Object> resultAdd)
internalAddProperty
in class PropertyMap<java.lang.Object,java.lang.Object>
propertyKey
- the key of the added propertyresultAdd
- the property to add to the map
PropertyMap.internalAddProperty(java.lang.Object,
org.deduced.Property)
public void recursivelyOverrideChildProperties(PropertyCollection<?,?> instance)
instance
- the instance to check for override on the parent listprivate void overridePropertiesOnChild(java.util.List<PropertyCollection<?,?>> instanceListToChild)
instanceListToChild
- the list of instances leading to a specific
child.private void applyRuleMissingOverride(PropertyCollection<?,?> rule, DeducedProperty<java.lang.Object> propertyOverride)
rule
- the rule to applypropertyOverride
- the property to use in the overridepublic static boolean isRuleApplicableToChild(PropertyCollection<?,?> ruleInstanceList, java.util.List<PropertyCollection<?,?>> instanceListToChild)
ruleInstanceList
- the rule output instance listinstanceListToChild
- the instance list to the child
public java.lang.Object setProperty(java.lang.Object propertyKey, java.lang.Object value)
setProperty
in interface PropertyCollection<java.lang.Object,java.lang.Object>
setProperty
in class PropertyMap<java.lang.Object,java.lang.Object>
propertyKey
- the key of the propertyvalue
- the new value of the property. If the property is a
collection that is not by reference, this method requires that
the passed collection has a parent set to null since it will
reset the parent.
PropertyMap.setProperty(java.lang.Object,
java.lang.Object)
protected boolean wasThePropertyReference(java.lang.Object propertyKey, java.lang.Object oldValue, boolean isReference)
propertyKey
- the property keyoldValue
- the old valueisReference
- is the property currently a reference
public java.lang.Object clone()
clone
in interface PropertyCollection<java.lang.Object,java.lang.Object>
clone
in class PropertyMap<java.lang.Object,java.lang.Object>
PropertyMap.clone()
protected void cleanNewlyClonedValue(AbstractPropertyCollection<java.lang.Object,java.lang.Object> newClone)
cleanNewlyClonedValue
in class PropertyMap<java.lang.Object,java.lang.Object>
newClone
- the newly created clone of the current collectionPropertyMap.cleanNewlyClonedValue(org.deduced.AbstractPropertyCollection)
public void delete()
delete
in interface PropertyCollection<java.lang.Object,java.lang.Object>
delete
in class AbstractPropertyCollection<java.lang.Object,java.lang.Object>
AbstractPropertyCollection.delete()
private void deleteAllDeductionRuleProperties()
public void removeDeductionRule(PropertyCollection<?,?> rule)
rule
- the rule to removeprivate void removeRuleOverrides(PropertyCollection<?,?> rule, DeducedProperty<java.lang.Object> propertyOverride)
rule
- the rule to removepropertyOverride
- the property that was used to override the rulepublic void addDeductionRule(PropertyCollection<?,?> rule)
rule
- the rule to add
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |