|
||||||||||
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.Integer,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) |
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)
attempt To Create Value |
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 Property<java.lang.Object> |
findMatchingRuleInMap(java.util.List<PropertyCollection<?,?>> reverseInstanceList,
java.util.List<PropertyCollection<?,?>> rulesToAvoid,
DynamicPropertyMap map)
find a rule in a property map that matches the reverse instance list and doesn't match one of the rules to avoid. |
private static Property<java.lang.Object> |
findOverride(PropertyCollection<?,?> searchPoint,
PropertyCollection<?,?> instance,
java.util.Collection<PropertyCollection<?,?>> parentListToAvoid,
java.util.List<PropertyCollection<?,?>> reverseInstanceList,
java.util.List<PropertyCollection<?,?>> rulesToAvoid)
find a property Override based on the parent list |
private void |
firePropertyChangeEventIfNecessary(PropertyCollection<?,?> instance,
java.lang.Integer key,
java.lang.Object oldValue,
java.lang.Object newValue)
fire Property Change Event If Necessary |
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 |
static java.lang.String |
getTypeName(PropertyCollection<?,?> collection)
get Type Name |
protected java.lang.Integer |
internalAddProperty(java.lang.Integer propertyKey,
Property<java.lang.Object> resultAdd)
(non-Javadoc) |
boolean |
isActivated()
(non-Javadoc) |
private static boolean |
isOutputDeeper(DynamicPropertyMap collectionToOverride,
DeducedProperty<java.lang.Object> property,
DeducedProperty<?> oldDeducedProperty)
is Output of the current rule Deeper than the current rule |
static boolean |
isRuleApplicableToChild(PropertyCollection<?,?> ruleInstanceList,
java.util.List<PropertyCollection<?,?>> instanceListToChild)
check if a Rule is Applicable To Child |
private void |
logRuleCreationResult(PropertyCollection deductionRule,
CompileResult result)
log Rule Creation Result |
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.Integer 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,
Property<?> property,
java.util.Collection<PropertyCollection<?,?>> parentListToAvoid,
java.util.List<PropertyCollection<?,?>> rulesToAvoid)
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 |
private boolean |
resetParentOnOldValue(java.lang.Integer propertyKey,
java.lang.Object oldValue,
boolean isReference)
reset Parent On Old Value |
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.Integer key,
DeducedProperty<java.lang.Object> property,
java.lang.Object newValue)
set Parent On New Value |
java.lang.Object |
setProperty(java.lang.Integer propertyKey,
java.lang.Object value)
(non-Javadoc) |
PropertyCollection<?,?> |
type()
(non-Javadoc) |
private void |
validateCreatedAnalyzerClass(java.lang.Object newInstance)
validate Created Analyzer Class |
private void |
validateOutputListSize(PropertyCollection deductionRule,
int outputListSize)
validate Output List Size. |
private void |
validateOutputType(PropertyCollection deductionRule,
PropertyCollection<?,?> output)
validate Output Type. |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
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 boolean isActivated()
isActivated
in interface PropertyCollection<java.lang.Integer,java.lang.Object>
isActivated
in class AbstractPropertyCollection<java.lang.Integer,java.lang.Object>
AbstractPropertyCollection.isActivated()
public void activate()
activate
in interface PropertyCollection<java.lang.Integer,java.lang.Object>
activate
in class AbstractPropertyCollection<java.lang.Integer,java.lang.Object>
AbstractPropertyCollection.activate()
private 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 void validateCreatedAnalyzerClass(java.lang.Object newInstance) throws java.lang.IllegalArgumentException
newInstance
- the potential analyzer
java.lang.IllegalArgumentException
- if the object isn't an instance of
DeductionRuleAnalyzerprivate 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)
deductionRule
- the deduction rule used to create the propertyanalyzer
- the analyzer used for the propertylastInstance
- the last instance in the rule output
private void logRuleCreationResult(PropertyCollection deductionRule, CompileResult result)
deductionRule
- the rule we tried to createresult
- the compilation resultprivate void validateOutputListSize(PropertyCollection deductionRule, int outputListSize)
deductionRule
- the rule we are creatingoutputListSize
- the output list sizeprivate void validateOutputType(PropertyCollection deductionRule, PropertyCollection<?,?> output)
deductionRule
- the rule we are creatingoutput
- the current outputprivate static void overridePropertyWithRule(DynamicPropertyMap collectionToOverride, java.lang.Integer 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.Integer 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 isOutputDeeper(DynamicPropertyMap collectionToOverride, DeducedProperty<java.lang.Object> property, DeducedProperty<?> oldDeducedProperty)
collectionToOverride
- the collection to overrideproperty
- the current rule we are trying to applyoldDeducedProperty
- the old rule
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.Integer 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.Integer,java.lang.Object>
setParent
in class AbstractPropertyCollection<java.lang.Integer,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, Property<?> property, java.util.Collection<PropertyCollection<?,?>> parentListToAvoid, java.util.List<PropertyCollection<?,?>> rulesToAvoid)
childCollection
- the child collection that contains the property to
rebuildproperty
- the previous propertyparentListToAvoid
- the list of parents to avoidrulesToAvoid
- the list of rules to avoidprivate static Property<java.lang.Object> findOverride(PropertyCollection<?,?> searchPoint, PropertyCollection<?,?> instance, java.util.Collection<PropertyCollection<?,?>> parentListToAvoid, java.util.List<PropertyCollection<?,?>> reverseInstanceList, java.util.List<PropertyCollection<?,?>> rulesToAvoid)
searchPoint
- the collection where to begin the searchinstance
- the instance that might need an overrideparentListToAvoid
- the list of parents to avoidreverseInstanceList
- the list of instances leading to this objectrulesToAvoid
- the list of rules to avoid
private static Property<java.lang.Object> findMatchingRuleInMap(java.util.List<PropertyCollection<?,?>> reverseInstanceList, java.util.List<PropertyCollection<?,?>> rulesToAvoid, DynamicPropertyMap map)
reverseInstanceList
- the reverse instance list of the rulerulesToAvoid
- 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.Integer,java.lang.Object>
removeProperty
in class PropertyMap<java.lang.Integer,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.Integer,java.lang.Object>
removePropertyInstance
in class PropertyMap<java.lang.Integer,java.lang.Object>
instance
- the object to remove
PropertyMap.removePropertyInstance(java.lang.Object)
public static java.lang.Object attemptToCreateValue(PropertyCollection<?,?> changedInstance)
changedInstance
- the value that changed
public static java.lang.Object createObjectIfBasicType(PropertyCollection<?,?> type)
type
- the type to create
public PropertyCollection<?,?> type()
type
in interface PropertyCollection<java.lang.Integer,java.lang.Object>
type
in class PropertyMap<java.lang.Integer,java.lang.Object>
PropertyMap.type()
protected java.lang.Integer internalAddProperty(java.lang.Integer propertyKey, Property<java.lang.Object> resultAdd)
internalAddProperty
in class PropertyMap<java.lang.Integer,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.Integer propertyKey, java.lang.Object value)
setProperty
in interface PropertyCollection<java.lang.Integer,java.lang.Object>
setProperty
in class PropertyMap<java.lang.Integer,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)
private boolean resetParentOnOldValue(java.lang.Integer propertyKey, java.lang.Object oldValue, boolean isReference)
propertyKey
- the old value keyoldValue
- the old valueisReference
- is the instance to the old value a reference
public java.lang.Object clone()
clone
in interface PropertyCollection<java.lang.Integer,java.lang.Object>
clone
in class PropertyMap<java.lang.Integer,java.lang.Object>
PropertyMap.clone()
public void delete()
delete
in interface PropertyCollection<java.lang.Integer,java.lang.Object>
delete
in class AbstractPropertyCollection<java.lang.Integer,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 |