org.deduced
Class DeducedUtilities

java.lang.Object
  extended by org.deduced.DeducedUtilities

public final class DeducedUtilities
extends java.lang.Object

Utility methods to analyze property collections

Author:
Steve McDuff

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
<T,V> T[]
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
<K,V,CK,X extends PropertyCollection<CK,? super V>>
X
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
<K,V,CK,X extends PropertyCollection<CK,? super V>>
X
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
<K,V,CK,X extends PropertyCollection<CK,V>>
K
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
<K,V> void
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

INITIAL_ORDER_INDEX

private static final int INITIAL_ORDER_INDEX
initial index used to fill an ordered list

See Also:
Constant Field Values

INDEX_INCREMENT

private static final int INDEX_INCREMENT
index increment to use

See Also:
Constant Field Values

LOGGER

private static final java.util.logging.Logger LOGGER
Logger

Constructor Detail

DeducedUtilities

public DeducedUtilities()
Method Detail

isInstanceOf

public static boolean isInstanceOf(PropertyCollection<?,?> objectType,
                                   PropertyCollection<?,?> testType)
Check if the object type contains the test type in it's parent hierarchy

Parameters:
objectType - the object type
testType - the type that might be a parent
Returns:
true if the test type is a parent of the object type.

isInstanceOfInternal

private static boolean isInstanceOfInternal(PropertyCollection<?,?> objectType,
                                            PropertyCollection<?,?> testType,
                                            java.util.Map<PropertyCollection<?,?>,PropertyCollection<?,?>> parsedTypeMap)
test if a type is an instance of another type. The parsed type map is used to remember which type were already checked for. It prevents a cyclic inheritance graph from causing a stack overflow.

Parameters:
objectType - the object type
testType - the type to test
parsedTypeMap - the list of types that have already been parsed
Returns:
true if the object type is an instance of the test type.

getDistanceBetweenTypes

public static int getDistanceBetweenTypes(PropertyCollection<?,?> objectType,
                                          PropertyCollection<?,?> testType)
finds out how many inheritance level is required to reach type

Parameters:
objectType - the lower type
testType - the parent type
Returns:
the number of inheritance steps between the two types. Returns -1 if there is no relationship. 0 if the types are the same.

getDistanceOnAbstractCollection

private static int getDistanceOnAbstractCollection(PropertyCollection<?,?> objectType,
                                                   PropertyCollection<?,?> testType,
                                                   int level)
internal recursive method to find the inheritance distance between two types.

Parameters:
objectType - the object type
testType - the type that might be in the parent list of the object type
level - the current inheritance level depth
Returns:
the inheritance level depth or Integer.MAX_VALUE if there are no relationships between the types.

getOrderedParentList

public static java.util.List<PropertyCollection<?,?>> getOrderedParentList(PropertyCollection<?,?> collection)
fetch the list of parents from the root node to the specified collection

Parameters:
collection - the last collection
Returns:
the list of parents from the root node to the specified collection

getCollectionRoot

public static PropertyCollection<?,?> getCollectionRoot(PropertyCollection<?,?> collection)
Fetch the root object that owns the whole object tree in which the specified collection is a part of.

Parameters:
collection - the collection in the tree
Returns:
the root parent

copyCollectionToArray

public static <T,V> T[] copyCollectionToArray(T[] array,
                                              java.util.Collection<V> collectionToConvert)
Utility method used to convert a collection to an array. The first array used as a parameter will be modified to contain the list of values contained in the collection. If the array is too small, it will be enlarged to fit the size of the collection. If the array is too big, remaining slots in the array will be set to null

Type Parameters:
T - the object type in the array to modify and return
V - the type of value from the collection to convert to array
Parameters:
array - the array that might be modified if the array is big enough
collectionToConvert - the collection that will be read and used to fill the returned array
Returns:
the array of values contained in the collection to convert

getCollectionName

public static java.lang.String getCollectionName(PropertyCollection<?,?> collection)
Fetch the name from a collection.

Parameters:
collection - the collection from which to fetch the name
Returns:
the name of the collection. If the collection is null, null is returned. If the collection isn't of type : NamedPropertyCollection, null is returned.

getPropertyPackagePropertyPackageList

public static PropertyCollection<?,?> getPropertyPackagePropertyPackageList(PropertyCollection<?,?> collection)
Utility method to get the list of sub package from a property package

Parameters:
collection - the property package
Returns:
the child package list

getBooleanProperty

public static boolean getBooleanProperty(PropertyCollection<?,?> collection,
                                         java.lang.Object key)
Utility method to get a boolean property form a collection

Parameters:
collection - the collection from which to fetch the value
key - the property key
Returns:
the property value as a native boolean

getIntegerProperty

public static int getIntegerProperty(PropertyCollection<?,?> collection,
                                     java.lang.Object key)
Utility method to get a integer property form a collection

Parameters:
collection - the collection from which to fetch the value
key - the property key
Returns:
the property value as a native integer

getFloatProperty

public static float getFloatProperty(PropertyCollection<?,?> collection,
                                     java.lang.Object key)
Utility method to get a float property form a collection

Parameters:
collection - the collection from which to fetch the value
key - the property key
Returns:
the property value as a native float

getDoubleProperty

public static double getDoubleProperty(PropertyCollection<?,?> collection,
                                       java.lang.Object key)
Utility method to get a double property form a collection

Parameters:
collection - the collection from which to fetch the value
key - the property key
Returns:
the property value as a native double

getStringProperty

public static java.lang.String getStringProperty(PropertyCollection<?,?> collection,
                                                 java.lang.Object key)
Utility method to get a String property form a collection

Parameters:
collection - the collection from which to fetch the value
key - the property key
Returns:
the property value as a String

getCollectionProperty

public static PropertyCollection<?,?> getCollectionProperty(PropertyCollection<?,?> collection,
                                                            java.lang.Object key)
Utility method to get a PropertyCollection property form a collection

Parameters:
collection - the collection from which to fetch the value
key - the property key
Returns:
the property value as a PropertyCollection

getPropertyCollectionTypeType

public static PropertyCollection<?,?> getPropertyCollectionTypeType()
Utility method to get the basic PropertyCollectionType type

Returns:
the basic PropertyCollectionType type

isInstanceTypeCollection

public static boolean isInstanceTypeCollection(PropertyCollection<?,?> instance)
check to see if the instance type of a property instance is a property collection

Parameters:
instance - the property instance
Returns:
true if the instance type is a property collection type

isTypeCollection

public static boolean isTypeCollection(PropertyCollection<?,?> type)
check if a type is used to define a property collection type

Parameters:
type - the type to verify
Returns:
true if the type is a property collection

findPackageInSchema

public static PropertyCollection<?,?> findPackageInSchema(PropertyCollection<?,?> schema,
                                                          java.lang.String[] packageNameList)
find a property package in a schema

Parameters:
schema - the schema to search from
packageNameList - the list of package names
Returns:
the matching package

findChildByName

public static PropertyCollection<?,?> findChildByName(PropertyCollection<?,?> listToSearch,
                                                      java.lang.String nameToFind)
find a child property collection by name

Parameters:
listToSearch - the list of named property collections
nameToFind - the name to find
Returns:
the first child collection that matches the required name

getParentOfType

public static PropertyCollection<?,?> getParentOfType(PropertyCollection<?,?> propertyCollection,
                                                      PropertyCollection<?,?> modelType)
fetch the parent of a collection that matches a certain type

Parameters:
propertyCollection - the collection to search from
modelType - the type to look for
Returns:
the matched parent of type

findChildPropertyCollectionKey

public static <K,V,CK,X extends PropertyCollection<CK,V>> K 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

Type Parameters:
K - the key type on the collection to search
V - the value type to search for on the child collections
CK - the key type on the child collections
X - the type of child collections on the collection to search
Parameters:
collectionToSearch - the collection to search
keyOnChildCollection - the child property key
valueOnChildCollection - the value of the child property
Returns:
the key of the child collection

findChildPropertyCollection

public static <K,V,CK,X extends PropertyCollection<CK,? super V>> X 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

Type Parameters:
K - the key type on the collection to search
V - the value type to search for on the child collections
CK - the key type on the child collections
X - the type of child collections on the collection to search
Parameters:
collectionToSearch - the collection to search
keyOnChildCollection - they key of the child property
valueOnChildCollection - the value of the child property
Returns:
the child collection

findChildPropertyCollectionByValueInstance

public static <K,V,CK,X extends PropertyCollection<CK,? super V>> X 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.

Type Parameters:
K - the key type on the collection to search
V - the value type to search for on the child collections
CK - the key type on the child collections
X - the type of child collections on the collection to search
Parameters:
collectionToSearch - the collection to search
keyOnChildCollection - they key of the child property
valueOnChildCollection - the value of the child property
Returns:
the child collection

isParentCollection

public static boolean isParentCollection(PropertyCollection<?,?> possibleParent,
                                         PropertyCollection<?,?> possibleChild)
check to see if a possible parent is a parent of the specified child collection

Parameters:
possibleParent - the possible parent
possibleChild - the possible child collection
Returns:
true if the possible parent is a parent of the child collection. False otherwise.

removeListenerSilent

public static <K,V> void removeListenerSilent(PropertyCollection<K,V> collection,
                                              PropertyListener<? super K,? super V> listener)
remove a property Listener Silently to a collection

Type Parameters:
K - the collection key type
V - the collection value type
Parameters:
listener - the listener to remove
collection - the collection from which to remove the listener

deleteQuietly

public static void deleteQuietly(PropertyCollection<?,?> collectionToDelete)
delete a collection quietly

Parameters:
collectionToDelete - the collection to delete

createNamedReferenceFinderFromModelLayer

public static NameReferenceFinder createNamedReferenceFinderFromModelLayer(PropertyCollection<?,?> modelLayer)
                                                                    throws java.lang.IllegalArgumentException
create a Named Reference Finder From a Model Layer

Parameters:
modelLayer - the model layer
Returns:
the created name reference finder
Throws:
java.lang.IllegalArgumentException - if the model isn't an instance of deduced model layer.

addPossibleModelLayerAndChildModelsToNameReferenceFinder

private static void addPossibleModelLayerAndChildModelsToNameReferenceFinder(PropertyCollection<?,?> modelLayer,
                                                                             NameReferenceFinderImplementation nameReferenceFinder)
add Model Layer and child models To Name Reference Finder

Parameters:
modelLayer - the model layer to add
nameReferenceFinder - the name reference finder in which to add the model and it's child models.

isModelLayer

protected static boolean isModelLayer(PropertyCollection<?,?> possibleModelLayer)
test if a collection is a model layer

Parameters:
possibleModelLayer - the possible model layer
Returns:
true if the collection is a model layer

addModelLayerDependentModelListToNameReferenceFinder

private static void addModelLayerDependentModelListToNameReferenceFinder(PropertyCollection<?,?> modelLayer,
                                                                         NameReferenceFinderImplementation nameReferenceFinder)
add Model Layer Dependent Model List To Name Reference Finder

Parameters:
modelLayer - the model layer to use
nameReferenceFinder - the name reference finder to use

addModelLayerCollectionListToNameReferenceFinder

private static void addModelLayerCollectionListToNameReferenceFinder(PropertyCollection<?,?> modelLayer,
                                                                     NameReferenceFinderImplementation nameReferenceFinder)
add Model Layer collection List To Name Reference Finder

Parameters:
modelLayer - the model layer to use
nameReferenceFinder - the name reference finder to use

addModelLayerToNameReferenceFinderIfNameIsValid

private static void addModelLayerToNameReferenceFinderIfNameIsValid(PropertyCollection<?,?> modelLayer,
                                                                    NameReferenceFinderImplementation nameReferenceFinder)
add Model Layer To Name Reference Finder only if it has a valid name

Parameters:
modelLayer - the model layer to add
nameReferenceFinder - the name reference finder in which to register the model layer

getNamePropertyValue

protected static java.lang.String getNamePropertyValue(PropertyCollection<?,?> namedCollection)
get Name Property Value

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.

Parameters:
namedCollection - the named collection
Returns:
the collection name

addAllModelLayersInListToNameReferenceFinder

private static void addAllModelLayersInListToNameReferenceFinder(NameReferenceFinderImplementation nameReferenceFinder,
                                                                 PropertyCollection<?,?> layerList)
parse a List of possible model layers And Add them all to a name Reference finder

Parameters:
nameReferenceFinder - the name reference finder to fill
layerList - the list of layers

isInstanceReference

protected static boolean isInstanceReference(PropertyCollection<?,?> instance)
return the is reference flag of a property 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.

Parameters:
instance - the instance from which to fetch the reference flag.
Returns:
the reference flag.

getParentList

protected static PropertyCollection<?,?> getParentList(PropertyCollection<?,?> collection)
Get the value of the instance : parent list

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.

Parameters:
collection - new collection from which to fetch the value
Returns:
parent list

getPropertyInstanceList

protected static PropertyCollection<?,?> getPropertyInstanceList(PropertyCollection<?,?> collection)
Get the value of the instance : property instance list

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.

Parameters:
collection - new collection from which to fetch the value
Returns:
property instance list

getInstanceType

protected static PropertyCollection<?,?> getInstanceType(PropertyCollection<?,?> collection)
Get the value of the instance : instance type

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.

Parameters:
collection - new collection from which to fetch the value
Returns:
instance type

getOrderedListContent

public 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. If the list isn't ordered, then the raw list content is returned and no ordering is performed.

Parameters:
orderedList - the ordered list
Returns:
the list of values within the list in the order in which it was defined.

getOrderedListContent

public 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. If the list isn't ordered, then the raw list content is returned and no ordering is performed.

Parameters:
orderedList - the ordered list
extractValue - option to extract the value from the ordering type
Returns:
the list of values within the list in the order in which it was defined.

extractValueFromCollectionList

public 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. Note, if one of the object in the collection list isn't a collection or doesn't contain a value matching the specified key, a null value will be inserted in the returned list, thereby guaranteeing that the order and size of the input will match the order and size of the output.

Parameters:
collectionList - the collection list from which to extract values
valueKey - the value key to extract
Returns:
the list of extracted property values

addObjectToOrderedListSilent

public 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. If any parameter is missing or if anything goes wrong during the addition, the addition will not be performed.

Parameters:
objectToAdd - the object to add to the list
orderedList - the ordered list in which to add the object
factory - the model factory used to create the intermediate object.

balanceManuallyOrderedList

public static int balanceManuallyOrderedList(PropertyCollection orderedList)
balance Manually Ordered List by resetting all indexes

Parameters:
orderedList - the ordered list to balance
Returns:
the new maximum index

getMaximumOrderedListIndex

public static int getMaximumOrderedListIndex(PropertyCollection orderedList)
get Maximum Ordered List Index. This method will always return a minimum value of zero.

Parameters:
orderedList - the ordered list from which to get the maximum index
Returns:
the maximum index

removeAllMatchingObjectFromOrderedListSilent

public static void removeAllMatchingObjectFromOrderedListSilent(PropertyCollection orderedList,
                                                                org.hamcrest.Matcher<?> removeMatcher)
Remove all the values in an ordered list that matches the specified criteria.

Parameters:
orderedList - the ordered list in which to add the object
removeMatcher - the matcher that determines if we remove an object or not.

getAllInheritedTypes

public 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

Parameters:
collectionType - the collection type from which to fetch all the inherited types.
Returns:
a collection of all the inherited types, including the initial collection type.

addCollectionToInheritedMap

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.

Parameters:
orderedInheritanceList - ordered list of inherited classes.
inheritedMap - the inherited map to fill used to prevent duplicate entries
collectionType - the current type to add

convertTextToType

public static java.lang.Object convertTextToType(java.lang.String text,
                                                 PropertyCollection<?,?> type)
                                          throws java.lang.IllegalArgumentException
convert Text To Type. Only basic types are supported by this method.

Parameters:
text - the text to convert.
type - the type to convert to.
Returns:
null if the text or the type is null. Returns an object matching the requested type
Throws:
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.

convertTextToTypePart1

private static java.lang.Object convertTextToTypePart1(java.lang.String text,
                                                       PropertyCollection<?,?> type)
convertTextToTypePart1 : fragment to reduce complexity rating

Parameters:
text - text to convert
type - type to convert
Returns:
converted value

convertTextToTypePart2

private static java.lang.Object convertTextToTypePart2(java.lang.String text,
                                                       PropertyCollection<?,?> type)
convertTextToTypePart2 : fragment to reduce complexity rating

Parameters:
text - text to convert
type - type to convert
Returns:
converted value

convertTextToBigInteger

public static java.lang.Object convertTextToBigInteger(java.lang.String text)
convert text to big integer

Parameters:
text - text to convert
Returns:
converted value
Throws:
java.lang.IllegalArgumentException - if the text is invalid for a big integer

convertTextToBigDecimal

public static java.lang.Object convertTextToBigDecimal(java.lang.String text)
convert text to big decimal

Parameters:
text - text to convert
Returns:
converted value
Throws:
java.lang.IllegalArgumentException - if the text is invalid for a big decimal

convertTextToDouble

public static java.lang.Object convertTextToDouble(java.lang.String text)
convert text to double

Parameters:
text - text to convert
Returns:
converted value
Throws:
java.lang.IllegalArgumentException - if the text is invalid for a double

convertTextToFloat

public static java.lang.Object convertTextToFloat(java.lang.String text)
convert text to float

Parameters:
text - text to convert
Returns:
converted value
Throws:
java.lang.IllegalArgumentException - if the text is invalid for a float

convertTextToCharacter

public static java.lang.Object convertTextToCharacter(java.lang.String text)
convert text to chracter

Parameters:
text - text to convert
Returns:
converted value
Throws:
java.lang.IllegalArgumentException - if the text is invalid for a character

convertTextToByte

public static java.lang.Object convertTextToByte(java.lang.String text)
convert text to byte

Parameters:
text - text to convert
Returns:
converted value
Throws:
java.lang.IllegalArgumentException - if the text is invalid for a byte

convertTextToShort

public static java.lang.Object convertTextToShort(java.lang.String text)
convert text to short

Parameters:
text - text to convert
Returns:
converted value
Throws:
java.lang.IllegalArgumentException - if the text is invalid for a short

convertTextToLong

public static java.lang.Object convertTextToLong(java.lang.String text)
convert text to long

Parameters:
text - text to convert
Returns:
converted value
Throws:
java.lang.IllegalArgumentException - if the text is invalid for a long

convertTextToInteger

public static java.lang.Object convertTextToInteger(java.lang.String text)
convert text to integer

Parameters:
text - text to convert
Returns:
converted value
Throws:
java.lang.IllegalArgumentException - if the text is invalid for a integer

convertTextToBoolean

public static java.lang.Object convertTextToBoolean(java.lang.String text)
convert text to boolean. Accepted values are 1,true,yes and 0,false,no

Parameters:
text - text to convert
Returns:
converted value
Throws:
java.lang.IllegalArgumentException - if the text is invalid for a boolean

sortCollectionListByProperty

public static void sortCollectionListByProperty(java.util.List<? extends PropertyCollection<?,?>> listToSort,
                                                java.lang.Object sortingPropertyKey)
sortCollectionListByProperty

Parameters:
listToSort - the list to sort
sortingPropertyKey - the sorting property key

printObject

public static void printObject(java.lang.StringBuilder build,
                               java.lang.Object value,
                               int spaceDepth,
                               int depthIncrement)
print Object in a JSON like format. There is no guarantee that this method will return the exact same string format in future versions. Use this method for debugging and logging only.

Parameters:
build - the string builder
value - the value to print
spaceDepth - amount of blank space to give to each line
depthIncrement - the amount of blank space depth to increment for each child object

printBlankSpace

public static void printBlankSpace(java.lang.StringBuilder build,
                                   java.lang.String repeatString,
                                   int repeatCount)
repeatedly print a string in a string builder

Parameters:
build - the string builder to use
repeatString - the string to repeat
repeatCount - the number of times to repeat the string