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 void
addFilter(FilterFactory ff, AttributeFactory af, UriFilter uf, Collection<Filter> filters)
static void
addFilter(FilterFactory ff, AttributeFactory af, String attrName, CollectionUriFilter cuf, Collection<Filter> filters)
static void
addFilter(FilterFactory ff, AttributeFactory af, String attrName, CollectionUuidFilter cuf, Collection<Filter> filters)
static void
addFilter(FilterFactory ff, Attribute attr, UuidFilter uf, Collection<Filter> filters)
static String
convertWildcardsToSql(String likeString)
protected static Filter
fromIlm(FilterFactory ff, AttributeFactory af, UriFilter uf)
protected static Filter
fromIlm(FilterFactory ff, AttributeFactory af, UriFilter.UriSelection us)
protected static Filter
fromIlm(FilterFactory ff, AttributeFactory af, String attrName, CollectionUriFilter cuf)
protected static Filter
fromIlm(FilterFactory ff, AttributeFactory af, String attrName, CollectionUuidFilter cuf)
protected static Filter
fromIlm(FilterFactory ff, Attribute attr, UuidFilter uf)
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 long
fromIlmInstant(Instant value)
Transforms the designatedInstant
to a simplelong
.static long
fromIlmInstant(Instant value, long nullValue)
Transforms the designatedInstant
to a simplelong
.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
.static Instant
toInstantPositive(long value)
Transforms the designatedlong
to anInstant
.static Instant
toInstantPositiveOrZero(long value)
Transforms the designatedlong
to anInstant
.
-
-
-
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.
-
toInstantPositive
public static Instant toInstantPositive(long value)
Transforms the designatedlong
to anInstant
. If the designatedlong
is not positive (<=0
),null
will be returned.- Parameters:
value
- The positive value which to transform toInstant
.- Returns:
- The designated
long
value asInstant
ornull
in case of0
or a negative value.
-
toInstantPositiveOrZero
public static Instant toInstantPositiveOrZero(long value)
Transforms the designatedlong
to anInstant
. If the designatedlong
is negative (<0
),null
will be returned.- Parameters:
value
- The non-negative value which to transform toInstant
.- Returns:
- The designated
long
value asInstant
ornull
in case of 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
.
-
fromIlmInstant
public static long fromIlmInstant(Instant value)
Transforms the designatedInstant
to a simplelong
. If the designatedInstant
isnull
,0
will be returned.- Parameters:
value
- The value which to transform tolong
.- Returns:
- The
long
value of the designatedInstant
or0
in case ofnull
.
-
fromIlmInstant
public static long fromIlmInstant(Instant value, long nullValue)
Transforms the designatedInstant
to a simplelong
. If the designatedInstant
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
long
value of the designatedInstant
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).
-
addFilter
public static void addFilter(FilterFactory ff, AttributeFactory af, UriFilter uf, Collection<Filter> filters)
-
fromIlm
protected static Filter fromIlm(FilterFactory ff, AttributeFactory af, UriFilter uf)
-
fromIlm
protected static Filter fromIlm(FilterFactory ff, AttributeFactory af, UriFilter.UriSelection us)
-
addFilter
public static void addFilter(FilterFactory ff, AttributeFactory af, String attrName, CollectionUriFilter cuf, Collection<Filter> filters)
-
fromIlm
protected static Filter fromIlm(FilterFactory ff, AttributeFactory af, String attrName, CollectionUriFilter cuf)
-
addFilter
public static void addFilter(FilterFactory ff, Attribute attr, UuidFilter uf, Collection<Filter> filters)
-
fromIlm
protected static Filter fromIlm(FilterFactory ff, Attribute attr, UuidFilter uf)
-
addFilter
public static void addFilter(FilterFactory ff, AttributeFactory af, String attrName, CollectionUuidFilter cuf, Collection<Filter> filters)
-
fromIlm
protected static Filter fromIlm(FilterFactory ff, AttributeFactory af, String attrName, CollectionUuidFilter cuf)
-
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
.
-
-