|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.deduced.rule.DeductionRuleLibrary
public abstract class DeductionRuleLibrary
DeductionRuleLibrary offers a set of quick methods to implement deduction rules
Nested Class Summary | |
---|---|
static class |
DeductionRuleLibrary.CompareResult
CompareResult is an utility class to store a collection and a value |
Field Summary | |
---|---|
private static java.util.logging.Logger |
LOGGER
Logger |
Constructor Summary | |
---|---|
DeductionRuleLibrary()
|
Method Summary | ||
---|---|---|
static PropertyCollection |
addReferenceToList(PropertyCollection referenceToAdd,
PropertyCollection list,
boolean allowDuplicateReference)
add a reference to a list. |
|
private static void |
addToRemoveListIfNotMatched(boolean removeUnmatchedValues,
java.util.List<PropertyCollection> objectsToRemove,
java.util.Collection valuesToMatchClone,
PropertyCollection currentCollection)
add a collection To the Remove List If Not Matched |
|
static Filter |
and(Filter firstFilter,
Filter secondFilter)
create an "and" filter |
|
static Filter |
bigger(java.lang.Object value)
Create a bigger than filter. |
|
static Filter |
biggerOrEqual(java.lang.Object value)
Create a bigger or equal to filter. |
|
static java.util.List<java.util.Calendar> |
createDateIncrementList(java.util.Calendar startDate,
java.util.Calendar endDate,
long incrementInMilliseconds)
create a Date Increment List |
|
static PropertyCollection |
createObject(PropertyCollection typeToCreate,
RuleExecutionContext context)
create an Object |
|
static PropertyCollection |
createObjectsMatchingAllValues(java.util.List valuesToMatch,
PropertyCollection listToAddMissingValues,
PropertyCollection instanceToMatch,
PropertyCollection typeToCreate,
boolean deleteUnmatchedValues,
RuleExecutionContext context)
create Objects Matching All Values and add them to the specified list |
|
static PropertyCollection |
createObjectsMatchingAllValues(java.util.List valuesToMatch,
PropertyCollection listToAddMissingValues,
PropertyCollection instanceToMatch,
PropertyCollection typeToCreate,
RuleExecutionContext context)
create Objects Matching All Values and add them to the specified list |
|
private static void |
createUnmatchedValues(PropertyCollection listToAddMissingValues,
PropertyCollection<?,?> collectionTypeToCreate,
java.lang.Object instanceKey,
java.util.List valuesToMatchClone,
ModelFactory modelFactory)
createUnmatchedValues |
|
static void |
debug(java.lang.String message)
utility method to output messages in the console quickly |
|
static Filter |
equalTo(java.lang.Object equalValue)
create a filter to where objects have to equal a specific value |
|
static PropertyCollection |
fillList(PropertyCollection listToFill,
java.util.List objectsToAddToList,
boolean removeUnmatchedValues)
fill a List with a list of objects. |
|
private static void |
fillListCreateUnmatchedValues(PropertyCollection listToFill,
java.util.Collection valuesToMatchClone)
fill List Create Unmatched Values |
|
private static void |
fillListExtractMatchesValues(boolean removeUnmatchedValues,
java.util.List currentValueCollectionList,
java.util.List<PropertyCollection> objectsToRemove,
java.util.Collection valuesToMatchClone)
fill List Extract Matches Values |
|
private static void |
fillListRemoveUnmatchedValues(PropertyCollection listToFill,
boolean isReference,
java.util.List<PropertyCollection> objectsToRemove)
fill List Remove Unmatched Values |
|
static
|
filter(java.util.List<T> listToFilter,
Filter condition)
filter a list based on a filter |
|
static java.lang.Object |
filterList(java.util.Collection listToFilter,
boolean nullOnMultipleResult)
filter a collection to extract a single object from it. |
|
static PropertyCollection<?,?> |
filterList(PropertyCollection<?,?> listToFilter,
boolean nullOnMultipleResult)
filter property collection to extract a single object from it. |
|
static
|
filterList(T[] listToFilter,
boolean nullOnMultipleResult)
filter an array property collection to extract a single object from it. |
|
private static DeductionRuleLibrary.CompareResult |
findMaximumResult(java.util.List collectionList,
PropertyCollection instanceToCompare)
find the maximum result in the list of property collection for the specified instance |
|
private static DeductionRuleLibrary.CompareResult |
findMinimumResult(java.util.List<?> collectionList,
PropertyCollection<?,?> instanceToCompare)
find the minimum result in the list of property collection for the specified instance |
|
static PropertyCollection |
findParentOfType(PropertyCollection searchPoint,
PropertyCollection type,
boolean matchExactType)
find Parent Of Type |
|
static java.lang.String |
formatDate(java.util.Calendar value)
format a date to show the year, month and day |
|
static java.lang.String |
formatDate(java.util.Calendar value,
java.lang.String dateFormat)
format Date to a string with a specific display format |
|
static java.lang.String |
formatTime(java.util.Calendar value)
format Time |
|
static Filter |
instanceOf(java.lang.Object type)
create a filter to where objects have to be of a specific type |
|
private static boolean |
isContextValid(RuleExecutionContext context)
is Context Valid |
|
private static boolean |
isCreationOptionsValid(java.util.List valuesToMatch,
PropertyCollection listToAddMissingValues,
PropertyCollection instanceToMatch,
PropertyCollection typeToCreate,
RuleExecutionContext context)
test if the options used to create collections are all valid |
|
private static boolean |
isTypeToCreateValid(PropertyCollection<?,?> typeToCreate)
is Type To Create Valid |
|
static PropertyCollection |
maximumCollection(java.util.List collectionList,
PropertyCollection instanceToCompare)
find the property collection in the list that has the maximum value for the specified instance |
|
static java.lang.Object |
maximumValue(java.util.List collectionList,
PropertyCollection instanceToCompare)
find the maximum value in the list of property collection for the specified instance |
|
static java.util.List |
merge(java.util.List firstList,
java.util.List secondList)
merge two list of objects together and return a list that contains the objects of the first list followed by the second list. |
|
static PropertyCollection |
minimumCollection(java.util.List collectionList,
PropertyCollection instanceToCompare)
find the property collection in the list that has the minimum value for the specified instance |
|
static java.lang.Object |
minimumValue(java.util.List collectionList,
PropertyCollection instanceToCompare)
find the minimum value in the list of property collection for the specified instance |
|
static Filter |
not(Filter otherFilter)
Create a reverse filter |
|
static Filter |
or(Filter firstFilter,
Filter secondFilter)
create an "or" filter |
|
static Filter |
property(PropertyCollection<?,?> instance,
Filter propertyValueFilter)
create a filter based on the value of a property and a filter applied to that value |
|
private static void |
removeAlreadyMatchedValues(boolean deleteUnmatchedValues,
java.lang.Object instanceKey,
java.util.List valuesToMatchClone,
java.util.List<PropertyCollection> valuesToRemove,
java.lang.Object possibleCollection)
remove Already Matched Values |
|
static Filter |
same(java.lang.Object sameInstance)
create a filter to where objects have to be the same as a specific value |
|
static Filter |
smaller(java.lang.Object value)
Create a smaller than filter. |
|
static Filter |
smallerOrEqual(java.lang.Object value)
Create a smaller or equal to filter. |
|
static int |
sum(java.lang.Integer first,
java.lang.Integer second)
sum two integers |
|
static double |
sum(java.util.List listOfNumbers)
sum a list of numbers |
|
private static void |
updateMaximumResultBasedOnCollection(DeductionRuleLibrary.CompareResult retVal,
java.lang.Integer instanceIdentityKey,
PropertyCollection collection)
update Maximum Result Based On Collection |
|
private static void |
updateMinimumResultWithCollection(DeductionRuleLibrary.CompareResult retVal,
java.lang.Integer instanceIdentityKey,
PropertyCollection<?,?> collection)
update Minimum Result With Collection |
|
private static void |
validateAddTypeToList(PropertyCollection list,
PropertyCollection<?,?> typeToAdd)
validate if an object of the specified property collection type can be added to a property collection |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.deduced.DeductionRuleAnalyzer |
---|
analyzeRule |
Field Detail |
---|
private static final java.util.logging.Logger LOGGER
Constructor Detail |
---|
public DeductionRuleLibrary()
Method Detail |
---|
public static java.lang.Object filterList(java.util.Collection listToFilter, boolean nullOnMultipleResult)
listToFilter
- the list to filternullOnMultipleResult
- if this flag is set to true and the list
contains more than 1 object, null will be returned.
public static PropertyCollection<?,?> filterList(PropertyCollection<?,?> listToFilter, boolean nullOnMultipleResult)
listToFilter
- the list to filternullOnMultipleResult
- if this flag is set to true and the list
contains more than 1 object, null will be returned.
public static <T> T filterList(T[] listToFilter, boolean nullOnMultipleResult)
T
- the type of object in the arraylistToFilter
- the list to filternullOnMultipleResult
- if this flag is set to true and the list
contains more than 1 object, null will be returned.
public static int sum(java.lang.Integer first, java.lang.Integer second)
first
- the first integersecond
- the second integer
public static double sum(java.util.List listOfNumbers)
listOfNumbers
- the list of numbers
public static PropertyCollection minimumCollection(java.util.List collectionList, PropertyCollection instanceToCompare)
collectionList
- the collection list to search ininstanceToCompare
- the instance to look for in the comparison of
values
public static java.lang.Object minimumValue(java.util.List collectionList, PropertyCollection instanceToCompare)
collectionList
- the collection list to search ininstanceToCompare
- the instance to look for in the comparison of
values
private static DeductionRuleLibrary.CompareResult findMinimumResult(java.util.List<?> collectionList, PropertyCollection<?,?> instanceToCompare)
collectionList
- the collection list to search ininstanceToCompare
- the instance to look for in the comparison of
values
private static void updateMinimumResultWithCollection(DeductionRuleLibrary.CompareResult retVal, java.lang.Integer instanceIdentityKey, PropertyCollection<?,?> collection)
retVal
- the compare result to updateinstanceIdentityKey
- the instance key to readcollection
- the collection to readpublic static PropertyCollection maximumCollection(java.util.List collectionList, PropertyCollection instanceToCompare)
collectionList
- the collection list to search ininstanceToCompare
- the instance to look for in the comparison of
values
public static java.lang.Object maximumValue(java.util.List collectionList, PropertyCollection instanceToCompare)
collectionList
- the collection list to search ininstanceToCompare
- the instance to look for in the comparison of
values
private static DeductionRuleLibrary.CompareResult findMaximumResult(java.util.List collectionList, PropertyCollection instanceToCompare)
collectionList
- the collection list to search ininstanceToCompare
- the instance to look for in the comparison of
values
private static void updateMaximumResultBasedOnCollection(DeductionRuleLibrary.CompareResult retVal, java.lang.Integer instanceIdentityKey, PropertyCollection collection)
retVal
- the result to updateinstanceIdentityKey
- the instance key to readcollection
- the collection to readpublic static java.lang.String formatDate(java.util.Calendar value)
value
- the value to format
public static java.lang.String formatTime(java.util.Calendar value)
value
- the time to format in a string
public static java.lang.String formatDate(java.util.Calendar value, java.lang.String dateFormat)
value
- the value to formatdateFormat
- the date format
public static PropertyCollection fillList(PropertyCollection listToFill, java.util.List objectsToAddToList, boolean removeUnmatchedValues)
listToFill
- the list to fillobjectsToAddToList
- objects to add to the listremoveUnmatchedValues
- if this option is set to true, all the
objects in the original list that don't match the list of
objects to add will be removed.
private static void fillListExtractMatchesValues(boolean removeUnmatchedValues, java.util.List currentValueCollectionList, java.util.List<PropertyCollection> objectsToRemove, java.util.Collection valuesToMatchClone)
removeUnmatchedValues
- the option to remove unmatched valuescurrentValueCollectionList
- the list of all the values that need to
be matchedobjectsToRemove
- the list of objects to potentially removevaluesToMatchClone
- the values to matchprivate static void fillListCreateUnmatchedValues(PropertyCollection listToFill, java.util.Collection valuesToMatchClone)
listToFill
- the list to fillvaluesToMatchClone
- the values to addprivate static void fillListRemoveUnmatchedValues(PropertyCollection listToFill, boolean isReference, java.util.List<PropertyCollection> objectsToRemove)
listToFill
- the list to fillisReference
- is the value to remove by referenceobjectsToRemove
- the list of values to removeprivate static void addToRemoveListIfNotMatched(boolean removeUnmatchedValues, java.util.List<PropertyCollection> objectsToRemove, java.util.Collection valuesToMatchClone, PropertyCollection currentCollection)
removeUnmatchedValues
- option to remove unmatched valuesobjectsToRemove
- the object to remove listvaluesToMatchClone
- the values to matchcurrentCollection
- the current collectionpublic static PropertyCollection createObject(PropertyCollection typeToCreate, RuleExecutionContext context)
typeToCreate
- the type of object to createcontext
- the rule execution context
public static PropertyCollection createObjectsMatchingAllValues(java.util.List valuesToMatch, PropertyCollection listToAddMissingValues, PropertyCollection instanceToMatch, PropertyCollection typeToCreate, RuleExecutionContext context)
valuesToMatch
- the values to matchlistToAddMissingValues
- the list to fillinstanceToMatch
- the instance where to set the value on each
created objecttypeToCreate
- the type of object to createcontext
- the rule execution context
public static PropertyCollection createObjectsMatchingAllValues(java.util.List valuesToMatch, PropertyCollection listToAddMissingValues, PropertyCollection instanceToMatch, PropertyCollection typeToCreate, boolean deleteUnmatchedValues, RuleExecutionContext context)
valuesToMatch
- the values to matchlistToAddMissingValues
- the list to fillinstanceToMatch
- the instance where to set the value on each
created objecttypeToCreate
- the type of object to createdeleteUnmatchedValues
- if this option is set to true, all the
objects in the original list that don't match the list of
values to add will be removed.context
- the rule execution context
private static boolean isCreationOptionsValid(java.util.List valuesToMatch, PropertyCollection listToAddMissingValues, PropertyCollection instanceToMatch, PropertyCollection typeToCreate, RuleExecutionContext context)
valuesToMatch
- the list of values to matchlistToAddMissingValues
- the list on which to add the missing valuesinstanceToMatch
- the instance to matchtypeToCreate
- the type to createcontext
- the context. The context must have a valid model factory
private static boolean isTypeToCreateValid(PropertyCollection<?,?> typeToCreate)
typeToCreate
- the type to create
private static boolean isContextValid(RuleExecutionContext context)
context
- the context
private static void createUnmatchedValues(PropertyCollection listToAddMissingValues, PropertyCollection<?,?> collectionTypeToCreate, java.lang.Object instanceKey, java.util.List valuesToMatchClone, ModelFactory modelFactory)
listToAddMissingValues
- the list on which to add the missing valuescollectionTypeToCreate
- the type of collection to createinstanceKey
- the instance key to setvaluesToMatchClone
- the list of values for which we should create
collectionsmodelFactory
- the model factory used for creationprivate static void removeAlreadyMatchedValues(boolean deleteUnmatchedValues, java.lang.Object instanceKey, java.util.List valuesToMatchClone, java.util.List<PropertyCollection> valuesToRemove, java.lang.Object possibleCollection)
deleteUnmatchedValues
- option to delete unmatched valuesinstanceKey
- the instance key to readvaluesToMatchClone
- the values to match listvaluesToRemove
- the values to remove listpossibleCollection
- the possible collection to removepublic static java.util.List<java.util.Calendar> createDateIncrementList(java.util.Calendar startDate, java.util.Calendar endDate, long incrementInMilliseconds)
startDate
- the start date inclusivelyendDate
- the end date inclusivelyincrementInMilliseconds
- the increment between each step in
milliseconds
public static <T> java.util.List<T> filter(java.util.List<T> listToFilter, Filter condition)
T
- Type of objects in the list to filterlistToFilter
- the list to filtercondition
- the condition filter
public static Filter bigger(java.lang.Object value)
value
- the bigger than value on the filter.
public static Filter smaller(java.lang.Object value)
value
- the smaller than value on the filter.
public static Filter biggerOrEqual(java.lang.Object value)
value
- the bigger or equal to value on the filter.
public static Filter smallerOrEqual(java.lang.Object value)
value
- the smaller or equal to value on the filter.
public static Filter not(Filter otherFilter)
otherFilter
- the filter to reverse
public static Filter equalTo(java.lang.Object equalValue)
equalValue
- the equal value
public static Filter property(PropertyCollection<?,?> instance, Filter propertyValueFilter)
instance
- the property instance to filterpropertyValueFilter
- the filter to apply to the value
public static Filter same(java.lang.Object sameInstance)
sameInstance
- the same value
public static Filter instanceOf(java.lang.Object type)
type
- the type to match
public static Filter and(Filter firstFilter, Filter secondFilter)
firstFilter
- first filtersecondFilter
- second filter
public static Filter or(Filter firstFilter, Filter secondFilter)
firstFilter
- first filtersecondFilter
- second filter
public static PropertyCollection findParentOfType(PropertyCollection searchPoint, PropertyCollection type, boolean matchExactType)
searchPoint
- the collection to search for a parent of the specified
typetype
- the type of the parent we are looking formatchExactType
- if this option is true, the parents must match the
exact specified type to be returned. Otherwise any type that
derives from the specified type will be returned.
public static java.util.List merge(java.util.List firstList, java.util.List secondList)
firstList
- the first list to add. This parameter can be null.secondList
- the second list to add. This parameter can be null.
public static void debug(java.lang.String message)
message
- the message to showpublic static PropertyCollection addReferenceToList(PropertyCollection referenceToAdd, PropertyCollection list, boolean allowDuplicateReference)
referenceToAdd
- the reference to add. If this parameter is null,
nothing occurs.list
- the list to which we are adding the reference. If this
parameter is null, nothing occurs.allowDuplicateReference
- flag indicating if the list is allowed to
contain duplicate references of the same object.
java.lang.IllegalArgumentException
- if the list doesn't allow addition of
references of the specified type or if the list doesn't
contain references.private static void validateAddTypeToList(PropertyCollection list, PropertyCollection<?,?> typeToAdd)
list
- the property collection listtypeToAdd
- the type to add
java.lang.IllegalArgumentException
- if the type to add can't be added.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |