public class DomainUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static Map<String,Object> |
buildEnvironmentFromXml(Node node,
Map<String,? extends Object> environment)
Builds the environment from the specified xml node.
|
static Object |
buildObject(String className,
Map<String,? extends Object> configuration)
Builds the object with the specified configuration.
|
static Object |
buildObjectFromXml(Node node,
Map<String,? extends Object> environment)
Builds object from the specified xml node.
|
static <T> Map<String,Object> |
convertPropertyMapIntoVelocityModel(Map<String,T> properties)
Converts property map into the velocity model.
|
static Date |
copyDate(Date source)
Null safe copy date function.
|
static Document |
createDocumentFromXmlBytes(byte[] bytes)
Creates the document from a given XML file, specified by bytes.
|
static Document |
createDocumentFromXmlFile(File file)
Creates the document from a given XML file.
|
static <K,V> Map<K,V> |
createMap(K key,
V val,
Object... data)
Wrapper function to create map from single line.
|
static <T> Set<T> |
createSet(T... a)
Wrapper function around java.util.Arrays.asList to create a set of objects.
|
static Object |
getPropertyByEnum(Object obj,
Enum<?> enm)
Returns object property by the specified enumeration name.
|
static <K,V> Map<K,V> |
mergeMaps(Map<K,V>... maps)
Merges several maps into one.
|
static boolean |
safeEquals(Object obj1,
Object obj2)
Null safe equals method.
|
static <T> List<T> |
softCopyList(Collection<T> source)
Null safe function for creating a soft copy of the list.
|
static <K,V> Map<K,V> |
softCopyMap(Map<K,V> source)
Null safe function for creating a soft copy of the map.
|
static <T> Set<T> |
softCopySet(Collection<T> source)
Null safe function for creating a soft copy of the set.
|
static <K,V> SortedMap<K,V> |
softCopySortedMap(Map<K,V> source)
Null safe function for creating a soft copy of the sorted map.
|
static <T extends Comparable<?>> |
softCopySortedSet(Collection<T> source)
Null safe function for creating a soft copy of the sorted set.
|
static <T> List<T> |
softCopyUnmodifiableList(Collection<T> source)
Null safe function for creating a unmodifiable soft copy of the list.
|
static <K,V> Map<K,V> |
softCopyUnmodifiableMap(Map<K,V> source)
Null safe function for creating an unmodifiable soft copy of the map.
|
static <T> Set<T> |
softCopyUnmodifiableSet(Collection<T> source)
Null safe function for creating an unmodifiable soft copy of the set.
|
static <K,V> SortedMap<K,V> |
softCopyUnmodifiableSortedMap(Map<K,V> source)
Null safe function for creating an unmodifiable soft copy of the sorted map.
|
static <T extends Comparable<?>> |
softCopyUnmodifiableSortedSet(Collection<T> source)
Null safe function for creating an unmodifiable soft copy of the sorted set.
|
static <T> List<List<T>> |
splitIntoLists(Collection<T> source,
int max)
Takes the collection and splits it into the several lists.
|
public static Date copyDate(Date source)
source - source date, can be nullpublic static <T> List<T> softCopyList(Collection<T> source)
T - inner object typesource - source object, can be any collectionpublic static <T> List<T> softCopyUnmodifiableList(Collection<T> source)
T - inner object typesource - source object, can be any collectionpublic static <T> Set<T> softCopySet(Collection<T> source)
T - inner object typesource - source object, can be any collectionpublic static <T> Set<T> softCopyUnmodifiableSet(Collection<T> source)
T - inner object typesource - source object, can be any collectionpublic static <T extends Comparable<?>> SortedSet<T> softCopySortedSet(Collection<T> source)
T - inner object typesource - source object, can be any collection, but elements mustpublic static <T extends Comparable<?>> SortedSet<T> softCopyUnmodifiableSortedSet(Collection<T> source)
T - inner object typesource - source object, can be any collection, but elements mustpublic static <K,V> Map<K,V> softCopyMap(Map<K,V> source)
K - key typeV - value typesource - source objectpublic static <K,V> Map<K,V> softCopyUnmodifiableMap(Map<K,V> source)
K - key typeV - value typesource - source objectpublic static <K,V> SortedMap<K,V> softCopySortedMap(Map<K,V> source)
K - key typeV - value typesource - source objectpublic static <K,V> SortedMap<K,V> softCopyUnmodifiableSortedMap(Map<K,V> source)
K - key typeV - value typesource - source objectpublic static <K,V> Map<K,V> mergeMaps(Map<K,V>... maps)
K - key typeV - value typemaps - maps to mergepublic static <T> Set<T> createSet(T... a)
T - object typea - objectspublic static <K,V> Map<K,V> createMap(K key, V val, Object... data)
K - key typeV - value typekey - first keyval - first valuedata - array with other keys and values, array goes [key1, value1, key2, value2...] and it is responsibility
of the caller to take care about class typespublic static <T> List<List<T>> splitIntoLists(Collection<T> source, int max)
T - inner object typesource - source collectionmax - maximum allowed number of elements per one list, must be positive numberpublic static Document createDocumentFromXmlFile(File file)
file - file to parsepublic static Document createDocumentFromXmlBytes(byte[] bytes)
bytes - bytes containing file to parsepublic static Object getPropertyByEnum(Object obj, Enum<?> enm)
obj - object from which property should be obtainedenm - enumeration which will be used to find the propertypublic static boolean safeEquals(Object obj1, Object obj2)
obj1 - first objectobj2 - second objectpublic static <T> Map<String,Object> convertPropertyMapIntoVelocityModel(Map<String,T> properties)
T - value typeproperties - properties to be convertedpublic static Object buildObject(String className, Map<String,? extends Object> configuration)
className - class name of the result object. This class must be public and have inner static class
called Builder which contains public default constructor and public method build.
Result of the build method is returned from this method.configuration - configuration for the builder. Keys are property names. Values are list of objects.
If there is a method set + upperCaseFirst(key), then this method is called. Otherwise exception is thrown.public static Object buildObjectFromXml(Node node, Map<String,? extends Object> environment)
<object>
<class>org.netwia.ObjectClass</class>
<configuration>
<property>
<name>property1</name>
<type>String</type>
<value>value1</value>
</property>
</configuration>
</object>
node - XML node to be parsed, expected to be the object node specified in the structureenvironment - environmentIndexOutOfBoundsException - in case of Dependency property points to the non existing key in the specified environmentpublic static Map<String,Object> buildEnvironmentFromXml(Node node, Map<String,? extends Object> environment)
node - xml node to parseenvironment - original environment which will be used for dependencies and included in the created oneIndexOutOfBoundsException - in case of Dependency property points to the non existing key
within the specified environment and other objects from xmlIllegalArgumentException - if name from xml is duplicated or points to the existing object in the environmentCopyright © 2016. All rights reserved.