Package de.aristaflow.ilm.util
Class Transformation
- java.lang.Object
-
- de.aristaflow.ilm.util.Transformation
-
public class Transformation extends Object
-
-
Constructor Summary
Constructors Constructor Description Transformation()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T extends Throwable>
TfromIlm(IlmException ilm, T af)
Takes over the stack trace and the cause (if available) from the designated ilm exception to the designated throwable.static boolean
fromIlmNull(Boolean value)
Transforms the designatedBoolean
to a simpleboolean
.static int
fromIlmNull(Integer value)
Transforms the designatedInteger
to a simpleint
.static int
fromIlmNull(Integer value, int nullValue)
Transforms the designatedLong
to a simplelong
.static long
fromIlmNull(Long value)
Transforms the designatedLong
to a simplelong
.static long
fromIlmNull(Long value, long nullValue)
Transforms the designatedLong
to a simplelong
.static ParameterException
toIlm(de.aristaflow.adept2.model.communication.webservice.ParameterException pe)
Transforms the designatedde.aristaflow.adept2.model.communication.webservice.ParameterException
to the corresponding (subclass of)de.aristaflow.ilm.utilParameterException
.static String
toIlm(Serializable serialisable)
Serialises the designated value and Base64-encodes it.static IlmException
toIlm(Throwable t)
Creates a newIlmException
that is closest to the designated throwable.static <K,V>
voidtoIlm(Map<K,V> map, Comparator<? super K> comp, Consumer<Map<K,V>> ilmField)
Makes a copy of the designated map and assigns it via the designated consumer to the corresponding field.static <K extends Comparable<? super K>,V>
voidtoIlm(Map<K,V> map, Consumer<Map<K,V>> ilmField)
Makes a copy of the designated map and assigns it via the designated consumer to the corresponding field.static Map<String,String>
toIlm(org.apache.commons.configuration2.Configuration conf)
Transforms the designated configuration to a string map.static Long
toIlmPositive(long value)
Transforms the designatedlong
toLong
.
-
-
-
Method Detail
-
toIlmPositive
public static Long toIlmPositive(long value)
Transforms the designatedlong
toLong
. If the designatedlong
is not positive (<=0
),null
will be returned.- Parameters:
value
- The positive value which to transform toLong
.- Returns:
- The designated
long
value ornull
in case of0
or a negative value.
-
toIlm
public static String toIlm(Serializable serialisable) throws IOException
Serialises the designated value and Base64-encodes it.- Parameters:
serialisable
- The value which to serialise and Base64-encode.- Returns:
- The designated serialised value Base64-encoded.
- Throws:
IOException
- If serialising or encoding the designated serialisable fails, anIOException
will be thrown.
-
toIlm
public static <K extends Comparable<? super K>,V> void toIlm(Map<K,V> map, Consumer<Map<K,V>> ilmField)
Makes a copy of the designated map and assigns it via the designated consumer to the corresponding field. The map entries will be sorted. If the map isnull
or empty,null
will be assigned.- Type Parameters:
K
- The type of the keys of the map.V
- The type of the values of the map.- Parameters:
map
- The map which to copy ornull
.ilmField
- The consumer setting the copy of the map to the corresponding field.
-
toIlm
public static <K,V> void toIlm(Map<K,V> map, Comparator<? super K> comp, Consumer<Map<K,V>> ilmField)
Makes a copy of the designated map and assigns it via the designated consumer to the corresponding field. The map entries will be sorted using the designated comparator. If the map isnull
or empty,null
will be assigned.- Type Parameters:
K
- The type of the keys of the map.V
- The type of the values of the map.- Parameters:
map
- The map which to copy ornull
.comp
- The comparator for sorting (the keys of) the map entry.ilmField
- The consumer setting the copy of the map to the corresponding field.
-
toIlm
public static ParameterException toIlm(de.aristaflow.adept2.model.communication.webservice.ParameterException pe)
Transforms the designatedde.aristaflow.adept2.model.communication.webservice.ParameterException
to the corresponding (subclass of)de.aristaflow.ilm.utilParameterException
.- Parameters:
pe
- Thede.aristaflow.adept2.model.communication.webservice.ParameterException
which to transform to the corresponding (subclass of)de.aristaflow.ilm.utilParameterException
.- Returns:
- The (subclass of)
de.aristaflow.ilm.utilParameterException
corresponding to the designatedde.aristaflow.adept2.model.communication.webservice.ParameterException
.
-
toIlm
public static Map<String,String> toIlm(org.apache.commons.configuration2.Configuration conf)
Transforms the designated configuration to a string map. The elements of the configuration will simply be transformed to a string usingObject.toString()
.- Parameters:
conf
- The configuration which to transform to a string map. This may benull
.- Returns:
- A string map containing the entries of the designated configuration or
null
in case the configuration isnull
or empty.
-
fromIlmNull
public static boolean fromIlmNull(Boolean value)
Transforms the designatedBoolean
to a simpleboolean
. If the designatedBoolean
isnull
,false
will be returned.- Parameters:
value
- The value which to transform toboolean
.- Returns:
- The designated
boolean
value orfalse
in case ofnull
.
-
fromIlmNull
public static int fromIlmNull(Integer value)
Transforms the designatedInteger
to a simpleint
. If the designatedInteger
isnull
,0
will be returned.- Parameters:
value
- The value which to transform toint
.- Returns:
- The designated
int
value or0
in case ofnull
.
-
fromIlmNull
public static int fromIlmNull(Integer value, int nullValue)
Transforms the designatedLong
to a simplelong
. If the designatedLong
isnull
, the designatednullValue
will be returned.- Parameters:
value
- The value which to transform tolong
.nullValue
- The value to use in case the designatedvalue
isnull
.- Returns:
- The designated
long
value or the designatednullValue
in case ofnull
.
-
fromIlmNull
public static long fromIlmNull(Long value)
Transforms the designatedLong
to a simplelong
. If the designatedLong
isnull
,0
will be returned.- Parameters:
value
- The value which to transform tolong
.- Returns:
- The designated
long
value or0
in case ofnull
.
-
fromIlmNull
public static long fromIlmNull(Long value, long nullValue)
Transforms the designatedLong
to a simplelong
. If the designatedLong
isnull
, the designatednullValue
will be returned.- Parameters:
value
- The value which to transform tolong
.nullValue
- The value to use in case the designatedvalue
isnull
.- Returns:
- The designated
long
value or the designatednullValue
in case ofnull
.
-
fromIlm
public static <T extends Throwable> T fromIlm(IlmException ilm, T af)
Takes over the stack trace and the cause (if available) from the designated ilm exception to the designated throwable.- Parameters:
ilm
- The ilm exception that occurred.af
- The throwable to be thrown into a service.- Returns:
- The throwable to be thrown into a service having the stack trace and the cause from the designated ilm exception (if available).
-
toIlm
public static IlmException toIlm(Throwable t)
Creates a newIlmException
that is closest to the designated throwable. This is either a subclass ofIlmException
corresponding to the designated throwable or aWrappingException
for a throwable that has no corresponding ILM exception.- Parameters:
t
- The throwable which to convert to an ILM exception.- Returns:
- The ILM exception that corresponds to the designated throwable or a
WrappingException
.
-
-