|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.deduced.PropertyImplementation<E> org.deduced.dynamic.AbstractDeducedProperty<E> org.deduced.dynamic.RuleDeducedProperty<E>
E
- the type of object being held in the propertypublic class RuleDeducedProperty<E>
RuleDeducedProperty is a property implementation that holds a property where the value is controlled by a deduction rule. This object has the responsibility to trigger the change events on all the other objects where the rule apply.
Field Summary | |
---|---|
private DeductionRuleAnalyzer<E> |
analyzer
analyzer used for the rule |
private static boolean |
DEBUG_RULES
flag used to enable or disable rule debugging. |
private static java.util.logging.Logger |
LOGGER
logger |
private ListenTargetTracker<java.lang.Object,java.lang.Object> |
ruleTriggerTracker
list of all the collections to which we listen to for changes in case we need to trigger the rule. |
private static long |
serialVersionUID
serial ID |
Constructor Summary | |
---|---|
RuleDeducedProperty(PropertyCollection<?,?> instance,
ContextualPropertyCollection<?,?> setParent,
PropertyCollection<?,?> setRule,
DeductionRuleAnalyzer<E> setAnalyzer,
E initialValue)
RuleDeducedProperty Constructor |
Method Summary | |
---|---|
private void |
addAllTriggers()
add All Triggers required to be monitored to execute a rule |
private void |
addListenerChainSkipLast(PropertyCollection<?,?> newValue,
PropertyCollection<?,?> instanceReference,
int index)
add a Listener Chain and Skip the last level since it doesn't need listeners at this point. |
private void |
addTrigger(PropertyCollection<?,?> newValue)
add a listener to a collection that could trigger the rule |
void |
applyRuleOverrideOnNewValueIfNecessary(E newValue,
PropertyCollection<?,?> lastInstance,
java.lang.Object objectOutput,
boolean isReference)
apply Rule Override On New Value If Necessary |
private boolean |
checkAllEventChain(PropertyChangeEvent<?,?> event)
check All inputs to see if an event triggered them |
private boolean |
checkEventChain(PropertyChangeEvent<?,?> event,
PropertyCollection<?,?> listenerChain,
PropertyCollection<?,?> instance,
int index)
check a chain of possible triggers on an event, move listeners if required |
private boolean |
checkEventChainOnChild(PropertyChangeEvent<?,?> event,
PropertyCollection<?,?> listenerChain,
int index,
PropertyCollection<?,?> childCollection)
check a chain of possible triggers on an event by looking at a specific child value, move listeners if required |
private boolean |
checkListEventChain(PropertyChangeEvent<?,?> event,
PropertyCollection<?,?> listenerChain,
int index,
PropertyCollection<?,?> subImplementation)
check a chain of possible triggers on an event, move listeners if required |
private void |
clearTriggerList()
clear the trigger list |
void |
delete()
(non-Javadoc) |
void |
deleteOldValueIfNecessary(E oldValue,
boolean isReference)
delete Old Value If Necessary |
protected void |
executeRule()
(non-JSDoc) |
private void |
fireChangeEventIfNecessary(E newValue,
E oldValue)
fire Change Event If Necessary |
private void |
fireNewValueChange(E newValue,
E oldValue)
fire New Value Change |
private void |
fireNewValueOnOutput(E newValue,
E oldValue,
PropertyCollection<?,?> lastInstance,
java.lang.Object instanceKey,
java.lang.Object output)
fire New Value On Output |
static java.util.List<PropertyCollection<java.lang.Object,java.lang.Object>> |
getRuleOutputList(PropertyCollection<?,?> startPoint,
PropertyCollection<?,?> rule)
get Rule Output List |
private boolean |
isEventRelatedToRuleInput(PropertyChangeEvent<?,?> event,
PropertyCollection<?,?> currentRuleInputCollection,
PropertyCollection<?,?> currentInputInstance)
test if an event is related to a rule input by verifying if it is either the "All Property Values" instance, or the event instance matches the current collection fixed instance or the current event key matches the rule input key. |
private void |
moveListenerChainSkipLast(PropertyChangeEvent<?,?> event,
PropertyCollection<?,?> propertyKey,
int index)
move collection Listener Chain and Skip the last level since it doesn't need listeners at this point. |
private void |
moveListenerChainSkipLast(PropertyCollection<?,?> propertyKey,
PropertyCollection<?,?> oldValue,
PropertyCollection<?,?> newValue,
int index)
move List Listener Chain and Skip the last level since it doesn't need listeners at this point. |
private void |
moveListListenerChainSkipLast(PropertyChangeEvent<?,?> event,
PropertyCollection<?,?> propertyKey,
int index)
move List Listener Chain and Skip the last level since it doesn't need listeners at this point. |
void |
propertyChanged(PropertyChangeEvent<?,?> event)
(non-Javadoc) |
private void |
removeListenerChainSkipLast(PropertyCollection<?,?> oldValue,
PropertyCollection<?,?> propertyKey,
int index)
remove Listener Chain and Skip the Last level since we didn't put listeners on it. |
private void |
removeTrigger(PropertyCollection<?,?> oldValue)
remove a listener on a collection that can't trigger the rule anymore |
void |
updateParentOnValueChange(E newValue,
E oldValue,
java.lang.Object instanceKey,
PropertyCollection<?,?> startCollection,
boolean isReference)
update Parent On Value Change |
static boolean |
validateListChildInstance(PropertyCollection<?,?> input,
PropertyCollection<?,?> listItemPropertyInstance,
PropertyCollection<?,?> listInstance,
PropertyCollection<?,?> rule)
validate List Child Instance matches the expected list instance |
Methods inherited from class org.deduced.dynamic.AbstractDeducedProperty |
---|
decrementUseCounter, executeRuleAnalyzer, getParent, getRule, getUseCounter, incrementUseCounter, logRuleExecutionException |
Methods inherited from class org.deduced.PropertyImplementation |
---|
arePropertiesEqual, arePropertyValuesEqual, clonePropertyValue, copy, equals, getInstance, getValue, getValueType, hashCode, isValueEqual, resetParentOnValue, setInstance, setValue, setValueOnProperty, setValueParent, toString |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.deduced.Property |
---|
copy, getInstance, getValue, getValueType, isValueEqual, setValue |
Field Detail |
---|
private static final java.util.logging.Logger LOGGER
private static final long serialVersionUID
private static final boolean DEBUG_RULES
private DeductionRuleAnalyzer<E> analyzer
private ListenTargetTracker<java.lang.Object,java.lang.Object> ruleTriggerTracker
Constructor Detail |
---|
public RuleDeducedProperty(PropertyCollection<?,?> instance, ContextualPropertyCollection<?,?> setParent, PropertyCollection<?,?> setRule, DeductionRuleAnalyzer<E> setAnalyzer, E initialValue)
instance
- instance of the rule outputsetParent
- object that owns the rulesetRule
- the deduction rule modelsetAnalyzer
- the deduction rule analyzerinitialValue
- initial value to use in case the rule execution failsMethod Detail |
---|
private void addAllTriggers()
public void propertyChanged(PropertyChangeEvent<?,?> event)
propertyChanged
in interface PropertyListener<java.lang.Object,java.lang.Object>
event
- the event that was generatedPropertyListener.propertyChanged(org.deduced.PropertyChangeEvent)
protected void executeRule()
executeRule
in class AbstractDeducedProperty<E>
AbstractDeducedProperty.executeRule()
private void fireChangeEventIfNecessary(E newValue, E oldValue)
newValue
- the property new valueoldValue
- the property new valueprivate void fireNewValueChange(E newValue, E oldValue)
newValue
- the property new valueoldValue
- the property old valuepublic void applyRuleOverrideOnNewValueIfNecessary(E newValue, PropertyCollection<?,?> lastInstance, java.lang.Object objectOutput, boolean isReference)
newValue
- the new valuelastInstance
- the instance for the new valueobjectOutput
- the object on which the override might applyisReference
- is the new value a referencepublic void deleteOldValueIfNecessary(E oldValue, boolean isReference)
oldValue
- the old valueisReference
- is the old value a referencepublic void updateParentOnValueChange(E newValue, E oldValue, java.lang.Object instanceKey, PropertyCollection<?,?> startCollection, boolean isReference)
newValue
- the new valueoldValue
- the old valueinstanceKey
- the instance keystartCollection
- the collection that will potentially be the new
parentisReference
- is the new value a reference.public static java.util.List<PropertyCollection<java.lang.Object,java.lang.Object>> getRuleOutputList(PropertyCollection<?,?> startPoint, PropertyCollection<?,?> rule)
startPoint
- the point where the rule is executedrule
- the rule model
private void fireNewValueOnOutput(E newValue, E oldValue, PropertyCollection<?,?> lastInstance, java.lang.Object instanceKey, java.lang.Object output)
newValue
- the new property valueoldValue
- the old property valuelastInstance
- the property instance of the propertyinstanceKey
- the instance keyoutput
- the collection that was modified by this eventpublic static boolean validateListChildInstance(PropertyCollection<?,?> input, PropertyCollection<?,?> listItemPropertyInstance, PropertyCollection<?,?> listInstance, PropertyCollection<?,?> rule)
input
- rule input modellistItemPropertyInstance
- the property instance used in the listlistInstance
- the expected list instance from the rulerule
- the deduction rule model
private boolean checkAllEventChain(PropertyChangeEvent<?,?> event)
event
- the event that was monitored
private boolean checkEventChain(PropertyChangeEvent<?,?> event, PropertyCollection<?,?> listenerChain, PropertyCollection<?,?> instance, int index)
event
- the event that was triggeredlistenerChain
- the instance reference object used to create the
listener chaininstance
- the current instance being monitoredindex
- index of they key in the instance reference
private boolean isEventRelatedToRuleInput(PropertyChangeEvent<?,?> event, PropertyCollection<?,?> currentRuleInputCollection, PropertyCollection<?,?> currentInputInstance)
event
- the current change eventcurrentRuleInputCollection
- the collection that might be related to
the change eventcurrentInputInstance
- the rule input instance being analyzed
private boolean checkEventChainOnChild(PropertyChangeEvent<?,?> event, PropertyCollection<?,?> listenerChain, int index, PropertyCollection<?,?> childCollection)
event
- the event that was triggeredlistenerChain
- the instance reference object used to create the
listener chainindex
- index of they key in the instance referencechildCollection
- the child collection for which we want to verify
if the event might be related.
private boolean checkListEventChain(PropertyChangeEvent<?,?> event, PropertyCollection<?,?> listenerChain, int index, PropertyCollection<?,?> subImplementation)
event
- the event that was triggeredlistenerChain
- the instance reference object used to create the
listener chainsubImplementation
- the current instance being monitoredindex
- index of they key in the instance reference
private void moveListListenerChainSkipLast(PropertyChangeEvent<?,?> event, PropertyCollection<?,?> propertyKey, int index)
event
- the event that was triggeredpropertyKey
- the instance reference that changedindex
- index of they key in the instance referenceprivate void moveListenerChainSkipLast(PropertyChangeEvent<?,?> event, PropertyCollection<?,?> propertyKey, int index)
event
- the event that was triggeredpropertyKey
- the instance reference that changedindex
- index of they key in the instance referenceprivate void moveListenerChainSkipLast(PropertyCollection<?,?> propertyKey, PropertyCollection<?,?> oldValue, PropertyCollection<?,?> newValue, int index)
propertyKey
- the instance reference that changedoldValue
- the value that we don't need to listen to anymorenewValue
- the new value we should listen to nowindex
- index of they key in the instance referenceprivate void addListenerChainSkipLast(PropertyCollection<?,?> newValue, PropertyCollection<?,?> instanceReference, int index)
instanceReference
- the instance reference that changednewValue
- the new value we should listen to nowindex
- index of they key in the instance referenceprivate void addTrigger(PropertyCollection<?,?> newValue)
newValue
- the collection to listen topublic void delete()
delete
in interface DeducedProperty<E>
delete
in class AbstractDeducedProperty<E>
DeducedProperty.delete()
private void clearTriggerList()
private void removeListenerChainSkipLast(PropertyCollection<?,?> oldValue, PropertyCollection<?,?> propertyKey, int index)
oldValue
- the old value we don't need to listen to anymorepropertyKey
- the instance reference being usedindex
- the index of the key in the instance referenceprivate void removeTrigger(PropertyCollection<?,?> oldValue)
oldValue
- the collection we don't need to listen to anymore
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |