|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.deduced.DeducedUtilities
public final class DeducedUtilities
Utility methods to analyze property collections
Field Summary | |
---|---|
private static int |
INDEX_INCREMENT
index increment to use |
private static int |
INITIAL_ORDER_INDEX
initial index used to fill an ordered list |
private static java.util.logging.Logger |
LOGGER
Logger |
Constructor Summary | |
---|---|
DeducedUtilities()
|
Method Summary | ||
---|---|---|
private static void |
addAllModelLayersInListToNameReferenceFinder(NameReferenceFinderImplementation nameReferenceFinder,
PropertyCollection<?,?> layerList)
parse a List of possible model layers And Add them all to a name Reference finder |
|
private static void |
addCollectionToInheritedMap(java.util.List<PropertyCollection<?,?>> orderedInheritanceList,
java.util.IdentityHashMap<PropertyCollection<?,?>,java.lang.Object> inheritedMap,
PropertyCollection<?,?> collectionType)
add a specific Collection To the Inherited Map and add all it's parents as well. |
|
private static void |
addModelLayerCollectionListToNameReferenceFinder(PropertyCollection<?,?> modelLayer,
NameReferenceFinderImplementation nameReferenceFinder)
add Model Layer collection List To Name Reference Finder |
|
private static void |
addModelLayerDependentModelListToNameReferenceFinder(PropertyCollection<?,?> modelLayer,
NameReferenceFinderImplementation nameReferenceFinder)
add Model Layer Dependent Model List To Name Reference Finder |
|
private static void |
addModelLayerToNameReferenceFinderIfNameIsValid(PropertyCollection<?,?> modelLayer,
NameReferenceFinderImplementation nameReferenceFinder)
add Model Layer To Name Reference Finder only if it has a valid name |
|
static void |
addObjectToOrderedListSilent(PropertyCollection<?,?> objectToAdd,
PropertyCollection orderedList,
ModelFactory factory)
add an Object To an Ordered List by creating the intermediate object type used to store the ordering info. |
|
private static void |
addPossibleModelLayerAndChildModelsToNameReferenceFinder(PropertyCollection<?,?> modelLayer,
NameReferenceFinderImplementation nameReferenceFinder)
add Model Layer and child models To Name Reference Finder |
|
static int |
balanceManuallyOrderedList(PropertyCollection orderedList)
balance Manually Ordered List by resetting all indexes |
|
static java.lang.Object |
convertTextToBigDecimal(java.lang.String text)
convert text to big decimal |
|
static java.lang.Object |
convertTextToBigInteger(java.lang.String text)
convert text to big integer |
|
static java.lang.Object |
convertTextToBoolean(java.lang.String text)
convert text to boolean. |
|
static java.lang.Object |
convertTextToByte(java.lang.String text)
convert text to byte |
|
static java.lang.Object |
convertTextToCharacter(java.lang.String text)
convert text to chracter |
|
static java.lang.Object |
convertTextToDouble(java.lang.String text)
convert text to double |
|
static java.lang.Object |
convertTextToFloat(java.lang.String text)
convert text to float |
|
static java.lang.Object |
convertTextToInteger(java.lang.String text)
convert text to integer |
|
static java.lang.Object |
convertTextToLong(java.lang.String text)
convert text to long |
|
static java.lang.Object |
convertTextToShort(java.lang.String text)
convert text to short |
|
static java.lang.Object |
convertTextToType(java.lang.String text,
PropertyCollection<?,?> type)
convert Text To Type. |
|
private static java.lang.Object |
convertTextToTypePart1(java.lang.String text,
PropertyCollection<?,?> type)
convertTextToTypePart1 : fragment to reduce complexity rating |
|
private static java.lang.Object |
convertTextToTypePart2(java.lang.String text,
PropertyCollection<?,?> type)
convertTextToTypePart2 : fragment to reduce complexity rating |
|
static
|
copyCollectionToArray(T[] array,
java.util.Collection<V> collectionToConvert)
Utility method used to convert a collection to an array. |
|
static NameReferenceFinder |
createNamedReferenceFinderFromModelLayer(PropertyCollection<?,?> modelLayer)
create a Named Reference Finder From a Model Layer |
|
static void |
deleteQuietly(PropertyCollection<?,?> collectionToDelete)
delete a collection quietly |
|
static java.util.List<java.lang.Object> |
extractValueFromCollectionList(java.util.List<?> collectionList,
java.lang.Object valueKey)
extract a value from each collection present in a list and return it in a list that matches the same order as the collection list. |
|
static PropertyCollection<?,?> |
findChildByName(PropertyCollection<?,?> listToSearch,
java.lang.String nameToFind)
find a child property collection by name |
|
static
|
findChildPropertyCollection(PropertyCollection<K,X> collectionToSearch,
CK keyOnChildCollection,
V valueOnChildCollection)
Find a child collection from the collection to search that has a property matching the specified key and value |
|
static
|
findChildPropertyCollectionByValueInstance(PropertyCollection<K,X> collectionToSearch,
CK keyOnChildCollection,
V valueOnChildCollection)
Find a child collection from the collection to search that has a property matching the specified key and value with the identity == operator. |
|
static
|
findChildPropertyCollectionKey(PropertyCollection<K,X> collectionToSearch,
CK keyOnChildCollection,
V valueOnChildCollection)
Find a child collection from the collection to search that has a property matching the specified key and value |
|
static PropertyCollection<?,?> |
findPackageInSchema(PropertyCollection<?,?> schema,
java.lang.String[] packageNameList)
find a property package in a schema |
|
static java.util.Collection<PropertyCollection<?,?>> |
getAllInheritedTypes(PropertyCollection<?,?> collectionType)
get All Inherited Types from a collection type in the order in which the root collection type inherits from them |
|
static boolean |
getBooleanProperty(PropertyCollection<?,?> collection,
java.lang.Object key)
Utility method to get a boolean property form a collection |
|
static java.lang.String |
getCollectionName(PropertyCollection<?,?> collection)
Fetch the name from a collection. |
|
static PropertyCollection<?,?> |
getCollectionProperty(PropertyCollection<?,?> collection,
java.lang.Object key)
Utility method to get a PropertyCollection property form a collection |
|
static PropertyCollection<?,?> |
getCollectionRoot(PropertyCollection<?,?> collection)
Fetch the root object that owns the whole object tree in which the specified collection is a part of. |
|
static int |
getDistanceBetweenTypes(PropertyCollection<?,?> objectType,
PropertyCollection<?,?> testType)
finds out how many inheritance level is required to reach type |
|
private static int |
getDistanceOnAbstractCollection(PropertyCollection<?,?> objectType,
PropertyCollection<?,?> testType,
int level)
internal recursive method to find the inheritance distance between two types. |
|
static double |
getDoubleProperty(PropertyCollection<?,?> collection,
java.lang.Object key)
Utility method to get a double property form a collection |
|
static float |
getFloatProperty(PropertyCollection<?,?> collection,
java.lang.Object key)
Utility method to get a float property form a collection |
|
protected static PropertyCollection<?,?> |
getInstanceType(PropertyCollection<?,?> collection)
Get the value of the instance : instance type |
|
static int |
getIntegerProperty(PropertyCollection<?,?> collection,
java.lang.Object key)
Utility method to get a integer property form a collection |
|
static int |
getMaximumOrderedListIndex(PropertyCollection orderedList)
get Maximum Ordered List Index. |
|
protected static java.lang.String |
getNamePropertyValue(PropertyCollection<?,?> namedCollection)
get Name Property Value |
|
static java.util.List<?> |
getOrderedListContent(PropertyCollection<?,?> orderedList)
get Ordered List Content will break down an ordered list by sorting all the ordering objects it contains based on the ordering instance and then extract the values stored in the ordering objects based on the value instance. |
|
static java.util.List<?> |
getOrderedListContent(PropertyCollection<?,?> orderedList,
boolean extractValue)
get Ordered List Content will break down an ordered list by sorting all the ordering objects it contains based on the ordering instance and then optionally extracting the values stored in the ordering objects based on the value instance. |
|
static java.util.List<PropertyCollection<?,?>> |
getOrderedParentList(PropertyCollection<?,?> collection)
fetch the list of parents from the root node to the specified collection |
|
protected static PropertyCollection<?,?> |
getParentList(PropertyCollection<?,?> collection)
Get the value of the instance : parent list |
|
static PropertyCollection<?,?> |
getParentOfType(PropertyCollection<?,?> propertyCollection,
PropertyCollection<?,?> modelType)
fetch the parent of a collection that matches a certain type |
|
static PropertyCollection<?,?> |
getPropertyCollectionTypeType()
Utility method to get the basic PropertyCollectionType type |
|
protected static PropertyCollection<?,?> |
getPropertyInstanceList(PropertyCollection<?,?> collection)
Get the value of the instance : property instance list |
|
static PropertyCollection<?,?> |
getPropertyPackagePropertyPackageList(PropertyCollection<?,?> collection)
Utility method to get the list of sub package from a property package |
|
static java.lang.String |
getStringProperty(PropertyCollection<?,?> collection,
java.lang.Object key)
Utility method to get a String property form a collection |
|
static boolean |
isInstanceOf(PropertyCollection<?,?> objectType,
PropertyCollection<?,?> testType)
Check if the object type contains the test type in it's parent hierarchy |
|
private static boolean |
isInstanceOfInternal(PropertyCollection<?,?> objectType,
PropertyCollection<?,?> testType,
java.util.Map<PropertyCollection<?,?>,PropertyCollection<?,?>> parsedTypeMap)
test if a type is an instance of another type. |
|
protected static boolean |
isInstanceReference(PropertyCollection<?,?> instance)
return the is reference flag of a property instance. |
|
static boolean |
isInstanceTypeCollection(PropertyCollection<?,?> instance)
check to see if the instance type of a property instance is a property collection |
|
protected static boolean |
isModelLayer(PropertyCollection<?,?> possibleModelLayer)
test if a collection is a model layer |
|
static boolean |
isParentCollection(PropertyCollection<?,?> possibleParent,
PropertyCollection<?,?> possibleChild)
check to see if a possible parent is a parent of the specified child collection |
|
static boolean |
isTypeCollection(PropertyCollection<?,?> type)
check if a type is used to define a property collection type |
|
static void |
printBlankSpace(java.lang.StringBuilder build,
java.lang.String repeatString,
int repeatCount)
repeatedly print a string in a string builder |
|
static void |
printObject(java.lang.StringBuilder build,
java.lang.Object value,
int spaceDepth,
int depthIncrement)
print Object in a JSON like format. |
|
static void |
removeAllMatchingObjectFromOrderedListSilent(PropertyCollection orderedList,
org.hamcrest.Matcher<?> removeMatcher)
Remove all the values in an ordered list that matches the specified criteria. |
|
static
|
removeListenerSilent(PropertyCollection<K,V> collection,
PropertyListener<? super K,? super V> listener)
remove a property Listener Silently to a collection |
|
static void |
sortCollectionListByProperty(java.util.List<? extends PropertyCollection<?,?>> listToSort,
java.lang.Object sortingPropertyKey)
sortCollectionListByProperty |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final int INITIAL_ORDER_INDEX
private static final int INDEX_INCREMENT
private static final java.util.logging.Logger LOGGER
Constructor Detail |
---|
public DeducedUtilities()
Method Detail |
---|
public static boolean isInstanceOf(PropertyCollection<?,?> objectType, PropertyCollection<?,?> testType)
objectType
- the object typetestType
- the type that might be a parent
private static boolean isInstanceOfInternal(PropertyCollection<?,?> objectType, PropertyCollection<?,?> testType, java.util.Map<PropertyCollection<?,?>,PropertyCollection<?,?>> parsedTypeMap)
objectType
- the object typetestType
- the type to testparsedTypeMap
- the list of types that have already been parsed
public static int getDistanceBetweenTypes(PropertyCollection<?,?> objectType, PropertyCollection<?,?> testType)
objectType
- the lower typetestType
- the parent type
private static int getDistanceOnAbstractCollection(PropertyCollection<?,?> objectType, PropertyCollection<?,?> testType, int level)
objectType
- the object typetestType
- the type that might be in the parent list of the object
typelevel
- the current inheritance level depth
public static java.util.List<PropertyCollection<?,?>> getOrderedParentList(PropertyCollection<?,?> collection)
collection
- the last collection
public static PropertyCollection<?,?> getCollectionRoot(PropertyCollection<?,?> collection)
collection
- the collection in the tree
public static <T,V> T[] copyCollectionToArray(T[] array, java.util.Collection<V> collectionToConvert)
T
- the object type in the array to modify and returnV
- the type of value from the collection to convert to arrayarray
- the array that might be modified if the array is big enoughcollectionToConvert
- the collection that will be read and used to
fill the returned array
public static java.lang.String getCollectionName(PropertyCollection<?,?> collection)
collection
- the collection from which to fetch the name
public static PropertyCollection<?,?> getPropertyPackagePropertyPackageList(PropertyCollection<?,?> collection)
collection
- the property package
public static boolean getBooleanProperty(PropertyCollection<?,?> collection, java.lang.Object key)
collection
- the collection from which to fetch the valuekey
- the property key
public static int getIntegerProperty(PropertyCollection<?,?> collection, java.lang.Object key)
collection
- the collection from which to fetch the valuekey
- the property key
public static float getFloatProperty(PropertyCollection<?,?> collection, java.lang.Object key)
collection
- the collection from which to fetch the valuekey
- the property key
public static double getDoubleProperty(PropertyCollection<?,?> collection, java.lang.Object key)
collection
- the collection from which to fetch the valuekey
- the property key
public static java.lang.String getStringProperty(PropertyCollection<?,?> collection, java.lang.Object key)
collection
- the collection from which to fetch the valuekey
- the property key
public static PropertyCollection<?,?> getCollectionProperty(PropertyCollection<?,?> collection, java.lang.Object key)
collection
- the collection from which to fetch the valuekey
- the property key
public static PropertyCollection<?,?> getPropertyCollectionTypeType()
public static boolean isInstanceTypeCollection(PropertyCollection<?,?> instance)
instance
- the property instance
public static boolean isTypeCollection(PropertyCollection<?,?> type)
type
- the type to verify
public static PropertyCollection<?,?> findPackageInSchema(PropertyCollection<?,?> schema, java.lang.String[] packageNameList)
schema
- the schema to search frompackageNameList
- the list of package names
public static PropertyCollection<?,?> findChildByName(PropertyCollection<?,?> listToSearch, java.lang.String nameToFind)
listToSearch
- the list of named property collectionsnameToFind
- the name to find
public static PropertyCollection<?,?> getParentOfType(PropertyCollection<?,?> propertyCollection, PropertyCollection<?,?> modelType)
propertyCollection
- the collection to search frommodelType
- the type to look for
public static <K,V,CK,X extends PropertyCollection<CK,V>> K findChildPropertyCollectionKey(PropertyCollection<K,X> collectionToSearch, CK keyOnChildCollection, V valueOnChildCollection)
K
- the key type on the collection to searchV
- the value type to search for on the child collectionsCK
- the key type on the child collectionsX
- the type of child collections on the collection to searchcollectionToSearch
- the collection to searchkeyOnChildCollection
- the child property keyvalueOnChildCollection
- the value of the child property
public static <K,V,CK,X extends PropertyCollection<CK,? super V>> X findChildPropertyCollection(PropertyCollection<K,X> collectionToSearch, CK keyOnChildCollection, V valueOnChildCollection)
K
- the key type on the collection to searchV
- the value type to search for on the child collectionsCK
- the key type on the child collectionsX
- the type of child collections on the collection to searchcollectionToSearch
- the collection to searchkeyOnChildCollection
- they key of the child propertyvalueOnChildCollection
- the value of the child property
public static <K,V,CK,X extends PropertyCollection<CK,? super V>> X findChildPropertyCollectionByValueInstance(PropertyCollection<K,X> collectionToSearch, CK keyOnChildCollection, V valueOnChildCollection)
K
- the key type on the collection to searchV
- the value type to search for on the child collectionsCK
- the key type on the child collectionsX
- the type of child collections on the collection to searchcollectionToSearch
- the collection to searchkeyOnChildCollection
- they key of the child propertyvalueOnChildCollection
- the value of the child property
public static boolean isParentCollection(PropertyCollection<?,?> possibleParent, PropertyCollection<?,?> possibleChild)
possibleParent
- the possible parentpossibleChild
- the possible child collection
public static <K,V> void removeListenerSilent(PropertyCollection<K,V> collection, PropertyListener<? super K,? super V> listener)
K
- the collection key typeV
- the collection value typelistener
- the listener to removecollection
- the collection from which to remove the listenerpublic static void deleteQuietly(PropertyCollection<?,?> collectionToDelete)
collectionToDelete
- the collection to deletepublic static NameReferenceFinder createNamedReferenceFinderFromModelLayer(PropertyCollection<?,?> modelLayer) throws java.lang.IllegalArgumentException
modelLayer
- the model layer
java.lang.IllegalArgumentException
- if the model isn't an instance of
deduced model layer.private static void addPossibleModelLayerAndChildModelsToNameReferenceFinder(PropertyCollection<?,?> modelLayer, NameReferenceFinderImplementation nameReferenceFinder)
modelLayer
- the model layer to addnameReferenceFinder
- the name reference finder in which to add the
model and it's child models.protected static boolean isModelLayer(PropertyCollection<?,?> possibleModelLayer)
possibleModelLayer
- the possible model layer
private static void addModelLayerDependentModelListToNameReferenceFinder(PropertyCollection<?,?> modelLayer, NameReferenceFinderImplementation nameReferenceFinder)
modelLayer
- the model layer to usenameReferenceFinder
- the name reference finder to useprivate static void addModelLayerCollectionListToNameReferenceFinder(PropertyCollection<?,?> modelLayer, NameReferenceFinderImplementation nameReferenceFinder)
modelLayer
- the model layer to usenameReferenceFinder
- the name reference finder to useprivate static void addModelLayerToNameReferenceFinderIfNameIsValid(PropertyCollection<?,?> modelLayer, NameReferenceFinderImplementation nameReferenceFinder)
modelLayer
- the model layer to addnameReferenceFinder
- the name reference finder in which to register
the model layerprotected static java.lang.String getNamePropertyValue(PropertyCollection<?,?> namedCollection)
This method is used to remove dependencies from the deduced package to the deduced.implementation package. The normal method to use is the one found in the generated implementation.
namedCollection
- the named collection
private static void addAllModelLayersInListToNameReferenceFinder(NameReferenceFinderImplementation nameReferenceFinder, PropertyCollection<?,?> layerList)
nameReferenceFinder
- the name reference finder to filllayerList
- the list of layersprotected static boolean isInstanceReference(PropertyCollection<?,?> instance)
This method is used to remove dependencies from the deduced package to the deduced.implementation package. The normal method to use is the one found in the generated implementation.
instance
- the instance from which to fetch the reference flag.
protected static PropertyCollection<?,?> getParentList(PropertyCollection<?,?> collection)
This method is used to remove dependencies from the deduced package to the deduced.implementation package. The normal method to use is the one found in the generated implementation.
collection
- new collection from which to fetch the value
protected static PropertyCollection<?,?> getPropertyInstanceList(PropertyCollection<?,?> collection)
This method is used to remove dependencies from the deduced package to the deduced.implementation package. The normal method to use is the one found in the generated implementation.
collection
- new collection from which to fetch the value
protected static PropertyCollection<?,?> getInstanceType(PropertyCollection<?,?> collection)
This method is used to remove dependencies from the deduced package to the deduced.implementation package. The normal method to use is the one found in the generated implementation.
collection
- new collection from which to fetch the value
public static java.util.List<?> getOrderedListContent(PropertyCollection<?,?> orderedList)
orderedList
- the ordered list
public static java.util.List<?> getOrderedListContent(PropertyCollection<?,?> orderedList, boolean extractValue)
orderedList
- the ordered listextractValue
- option to extract the value from the ordering type
public static java.util.List<java.lang.Object> extractValueFromCollectionList(java.util.List<?> collectionList, java.lang.Object valueKey)
collectionList
- the collection list from which to extract valuesvalueKey
- the value key to extract
public static void addObjectToOrderedListSilent(PropertyCollection<?,?> objectToAdd, PropertyCollection orderedList, ModelFactory factory)
objectToAdd
- the object to add to the listorderedList
- the ordered list in which to add the objectfactory
- the model factory used to create the intermediate object.public static int balanceManuallyOrderedList(PropertyCollection orderedList)
orderedList
- the ordered list to balance
public static int getMaximumOrderedListIndex(PropertyCollection orderedList)
orderedList
- the ordered list from which to get the maximum index
public static void removeAllMatchingObjectFromOrderedListSilent(PropertyCollection orderedList, org.hamcrest.Matcher<?> removeMatcher)
orderedList
- the ordered list in which to add the objectremoveMatcher
- the matcher that determines if we remove an object
or not.public static java.util.Collection<PropertyCollection<?,?>> getAllInheritedTypes(PropertyCollection<?,?> collectionType)
collectionType
- the collection type from which to fetch all the
inherited types.
private static void addCollectionToInheritedMap(java.util.List<PropertyCollection<?,?>> orderedInheritanceList, java.util.IdentityHashMap<PropertyCollection<?,?>,java.lang.Object> inheritedMap, PropertyCollection<?,?> collectionType)
orderedInheritanceList
- ordered list of inherited classes.inheritedMap
- the inherited map to fill used to prevent duplicate
entriescollectionType
- the current type to addpublic static java.lang.Object convertTextToType(java.lang.String text, PropertyCollection<?,?> type) throws java.lang.IllegalArgumentException
text
- the text to convert.type
- the type to convert to.
java.lang.IllegalArgumentException
- if the text is invalid for the requested
type or if the type to convert to isn't supported by this
method.private static java.lang.Object convertTextToTypePart1(java.lang.String text, PropertyCollection<?,?> type)
text
- text to converttype
- type to convert
private static java.lang.Object convertTextToTypePart2(java.lang.String text, PropertyCollection<?,?> type)
text
- text to converttype
- type to convert
public static java.lang.Object convertTextToBigInteger(java.lang.String text)
text
- text to convert
java.lang.IllegalArgumentException
- if the text is invalid for a big integerpublic static java.lang.Object convertTextToBigDecimal(java.lang.String text)
text
- text to convert
java.lang.IllegalArgumentException
- if the text is invalid for a big decimalpublic static java.lang.Object convertTextToDouble(java.lang.String text)
text
- text to convert
java.lang.IllegalArgumentException
- if the text is invalid for a doublepublic static java.lang.Object convertTextToFloat(java.lang.String text)
text
- text to convert
java.lang.IllegalArgumentException
- if the text is invalid for a floatpublic static java.lang.Object convertTextToCharacter(java.lang.String text)
text
- text to convert
java.lang.IllegalArgumentException
- if the text is invalid for a characterpublic static java.lang.Object convertTextToByte(java.lang.String text)
text
- text to convert
java.lang.IllegalArgumentException
- if the text is invalid for a bytepublic static java.lang.Object convertTextToShort(java.lang.String text)
text
- text to convert
java.lang.IllegalArgumentException
- if the text is invalid for a shortpublic static java.lang.Object convertTextToLong(java.lang.String text)
text
- text to convert
java.lang.IllegalArgumentException
- if the text is invalid for a longpublic static java.lang.Object convertTextToInteger(java.lang.String text)
text
- text to convert
java.lang.IllegalArgumentException
- if the text is invalid for a integerpublic static java.lang.Object convertTextToBoolean(java.lang.String text)
text
- text to convert
java.lang.IllegalArgumentException
- if the text is invalid for a booleanpublic static void sortCollectionListByProperty(java.util.List<? extends PropertyCollection<?,?>> listToSort, java.lang.Object sortingPropertyKey)
listToSort
- the list to sortsortingPropertyKey
- the sorting property keypublic static void printObject(java.lang.StringBuilder build, java.lang.Object value, int spaceDepth, int depthIncrement)
build
- the string buildervalue
- the value to printspaceDepth
- amount of blank space to give to each linedepthIncrement
- the amount of blank space depth to increment for
each child objectpublic static void printBlankSpace(java.lang.StringBuilder build, java.lang.String repeatString, int repeatCount)
build
- the string builder to userepeatString
- the string to repeatrepeatCount
- the number of times to repeat the string
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |