|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.deduced.PropertyImplementation<E>
org.deduced.framework.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.
| Nested Class Summary | |
|---|---|
protected static class |
RuleDeducedProperty.ParameterFetcher
ParameterFetcher is a class used to breakdown a list of parameters while fetching inputs. |
| Field Summary | |
|---|---|
private DeductionRuleAnalyzer<E> |
analyzer
analyzer used for the rule |
private RuleExecutionContext |
context
rule execution context |
private static boolean |
DEBUG_RULES
flag used to enable or disable rule debugging. |
private static java.util.logging.Logger |
LOGGER
logger |
private PropertyCollection<?,?> |
parent
property collection that holds the rule |
private PropertyCollection |
rule
model of the deduction rule |
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,
PropertyCollection<?,?> setParent,
PropertyCollection<?,?> setRule,
DeductionRuleAnalyzer<E> setAnalyzer,
RuleExecutionContext setContext)
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 |
private static java.util.List<java.lang.Object> |
breakList(java.util.List<?> returnArray,
java.lang.Object childKey,
boolean splitSubList)
break a list of values to fetch a sub value based on a key in each element |
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 |
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) |
private void |
executeRule()
execute Rule |
private static void |
fetchNextLevelOfValues(PropertyCollection<?,?> input,
PropertyCollection<?,?> rule,
RuleDeducedProperty.ParameterFetcher fetcher,
java.util.Iterator<?> iterator,
PropertyCollection<?,?> propertyInstance)
fetch Next Level Of Values |
private static java.lang.Object |
fetchParameterFromKeyList(PropertyCollection<?,?> startPoint,
PropertyCollection<?,?> input,
PropertyCollection<?,?> rule,
boolean skipLast)
fetch all the values that match the defined input by starting at the specified start point and digging down the property tree |
private static PropertyCollection<?,?> |
fetchPotentialValueFixedInstance(java.lang.Object currentReturnValue)
fetch Potential Value Fixed Instance |
private static PropertyCollection<?,?> |
fetchStartCollection(PropertyCollection<?,?> ruleParent,
PropertyCollection<?,?> instanceReference)
fetch the collection that is used as a starting point to analyze an instance reference. |
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.Integer instanceKey,
java.lang.Object output)
fire New Value On Output |
PropertyCollection<?,?> |
getParent()
(non-Javadoc) |
PropertyCollection<?,?> |
getRule()
(non-Javadoc) |
static java.util.List<PropertyCollection<java.lang.Integer,java.lang.Object>> |
getRuleOutputList(PropertyCollection<?,?> startPoint,
PropertyCollection<?,?> rule)
get Rule Output List |
private static boolean |
isListInstance(PropertyCollection<?,?> propertyInstance)
is List Instance |
private static boolean |
isNextInstanceInInputValidForList(PropertyCollection<?,?> input,
PropertyCollection<?,?> rule,
PropertyCollection<?,?> propertyInstance,
boolean isPropertyCollectionList,
PropertyCollection<?,?> fixedInstance,
PropertyCollection<?,?> listItemPropertyInstance)
is the Next Instance In Input Valid For List |
private static boolean |
isSplittingOfSingleListRequired(java.util.Iterator<?> iterator,
boolean isPropertyCollectionList,
PropertyCollection<?,?> fixedInstance,
java.lang.Object currentRetVal)
test if Splitting Of Single List is Required |
private static boolean |
isSplittingOfSubListRequired(PropertyCollection<?,?> input,
PropertyCollection<?,?> rule,
RuleDeducedProperty.ParameterFetcher fetcher,
java.util.Iterator<?> iterator,
PropertyCollection<?,?> propertyInstance,
java.util.List<?> currentValue)
is Splitting Of Sub List Required |
private void |
logRuleExecutionException(java.lang.Exception e)
log Rule Execution Exception |
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 |
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.PropertyImplementation |
|---|
arePropertiesEqual, arePropertyValuesEqual, clonePropertyValue, copy, equals, getInstance, getValue, getValueType, hashCode, isValueEqual, resetParentOnValue, 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 PropertyCollection<?,?> parent
private PropertyCollection rule
private ListenTargetTracker<java.lang.Object,java.lang.Object> ruleTriggerTracker
private RuleExecutionContext context
| Constructor Detail |
|---|
public RuleDeducedProperty(PropertyCollection<?,?> instance,
PropertyCollection<?,?> setParent,
PropertyCollection<?,?> setRule,
DeductionRuleAnalyzer<E> setAnalyzer,
RuleExecutionContext setContext)
instance - instance of the rule outputsetParent - object that owns the rulesetRule - the deduction rule modelsetAnalyzer - the deduction rule analyzersetContext - the rule execution context| Method Detail |
|---|
public PropertyCollection<?,?> getRule()
getRule in interface DeducedProperty<E>DeducedProperty.getRule()private void addAllTriggers()
private static PropertyCollection<?,?> fetchStartCollection(PropertyCollection<?,?> ruleParent,
PropertyCollection<?,?> instanceReference)
ruleParent - the parent of the ruleinstanceReference - the instance reference to use
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)private void executeRule()
private void logRuleExecutionException(java.lang.Exception e)
e - the unexpected exception
private void fireChangeEventIfNecessary(E newValue,
E oldValue)
newValue - the property new valueoldValue - the property new value
private void fireNewValueChange(E newValue,
E oldValue)
newValue - the property new valueoldValue - the property old value
public static java.util.List<PropertyCollection<java.lang.Integer,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.Integer 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 event
private static java.lang.Object fetchParameterFromKeyList(PropertyCollection<?,?> startPoint,
PropertyCollection<?,?> input,
PropertyCollection<?,?> rule,
boolean skipLast)
startPoint - the key list start pointinput - the JavaRuleInput containing a key listrule - the rule modelskipLast - option to skip the last level of the key list. Useful to
extract the list of collections that contain the last level of
values.
private static void fetchNextLevelOfValues(PropertyCollection<?,?> input,
PropertyCollection<?,?> rule,
RuleDeducedProperty.ParameterFetcher fetcher,
java.util.Iterator<?> iterator,
PropertyCollection<?,?> propertyInstance)
input - the rule inputrule - the rule we are fetching information forfetcher - the current fetching resultsiterator - the input instance iteratorpropertyInstance - the current instance we are fetching
private static boolean isNextInstanceInInputValidForList(PropertyCollection<?,?> input,
PropertyCollection<?,?> rule,
PropertyCollection<?,?> propertyInstance,
boolean isPropertyCollectionList,
PropertyCollection<?,?> fixedInstance,
PropertyCollection<?,?> listItemPropertyInstance)
input - the input we are validatingrule - the rule which contains the inputpropertyInstance - the current property instanceisPropertyCollectionList - is the instance a property collection
listfixedInstance - the required list fixed instancelistItemPropertyInstance - the actual next instance in the input
list
private static boolean isSplittingOfSingleListRequired(java.util.Iterator<?> iterator,
boolean isPropertyCollectionList,
PropertyCollection<?,?> fixedInstance,
java.lang.Object currentRetVal)
iterator - the input iteratorisPropertyCollectionList - is the currentfixedInstance - the actual fixed instance of the current value we
are splittingcurrentRetVal - the current value we are splitting
private static PropertyCollection<?,?> fetchPotentialValueFixedInstance(java.lang.Object currentReturnValue)
currentReturnValue - the current value
private static boolean isSplittingOfSubListRequired(PropertyCollection<?,?> input,
PropertyCollection<?,?> rule,
RuleDeducedProperty.ParameterFetcher fetcher,
java.util.Iterator<?> iterator,
PropertyCollection<?,?> propertyInstance,
java.util.List<?> currentValue)
input - the rule input we are splittingrule - the rule we are analyzingfetcher - the fetching resultsiterator - the input iteratorpropertyInstance - the current instance we are potentially splittingcurrentValue - the list of current values
private static boolean isListInstance(PropertyCollection<?,?> propertyInstance)
propertyInstance - the possible list instance
public 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 static java.util.List<java.lang.Object> breakList(java.util.List<?> returnArray,
java.lang.Object childKey,
boolean splitSubList)
returnArray - the array of value to fetch the sub valuechildKey - the key of the sub valuesplitSubList - option to also break the sub values right away in the
output
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 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 reference
private 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 reference
private 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 reference
private 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>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 anymorepublic PropertyCollection<?,?> getParent()
getParent in interface DeducedProperty<E>DeducedProperty.getParent()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||