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 voidaddFilter(FilterFactory ff, AttributeFactory af, UriFilter uf, Collection<Filter> filters)static voidaddFilter(FilterFactory ff, AttributeFactory af, String attrName, CollectionUriFilter cuf, Collection<Filter> filters)static voidaddFilter(FilterFactory ff, AttributeFactory af, String attrName, CollectionUuidFilter cuf, Collection<Filter> filters)static voidaddFilter(FilterFactory ff, Attribute attr, UuidFilter uf, Collection<Filter> filters)static StringconvertWildcardsToSql(String likeString)protected static FilterfromIlm(FilterFactory ff, AttributeFactory af, UriFilter uf)protected static FilterfromIlm(FilterFactory ff, AttributeFactory af, UriFilter.UriSelection us)protected static FilterfromIlm(FilterFactory ff, AttributeFactory af, String attrName, CollectionUriFilter cuf)protected static FilterfromIlm(FilterFactory ff, AttributeFactory af, String attrName, CollectionUuidFilter cuf)protected static FilterfromIlm(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 longfromIlmInstant(Instant value)Transforms the designatedInstantto a simplelong.static longfromIlmInstant(Instant value, long nullValue)Transforms the designatedInstantto a simplelong.static booleanfromIlmNull(Boolean value)Transforms the designatedBooleanto a simpleboolean.static intfromIlmNull(Integer value)Transforms the designatedIntegerto a simpleint.static intfromIlmNull(Integer value, int nullValue)Transforms the designatedLongto a simplelong.static longfromIlmNull(Long value)Transforms the designatedLongto a simplelong.static longfromIlmNull(Long value, long nullValue)Transforms the designatedLongto a simplelong.static ParameterExceptiontoIlm(de.aristaflow.adept2.model.communication.webservice.ParameterException pe)Transforms the designatedde.aristaflow.adept2.model.communication.webservice.ParameterExceptionto the corresponding (subclass of)de.aristaflow.ilm.utilParameterException.static StringtoIlm(Serializable serialisable)Serialises the designated value and Base64-encodes it.static IlmExceptiontoIlm(Throwable t)Creates a newIlmExceptionthat 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 LongtoIlmPositive(long value)Transforms the designatedlongtoLong.static InstanttoInstantPositive(long value)Transforms the designatedlongto anInstant.static InstanttoInstantPositiveOrZero(long value)Transforms the designatedlongto anInstant.
-
-
-
Method Detail
-
toIlmPositive
public static Long toIlmPositive(long value)
Transforms the designatedlongtoLong. If the designatedlongis not positive (<=0),nullwill be returned.- Parameters:
value- The positive value which to transform toLong.- Returns:
- The designated
longvalue ornullin case of0or a negative value.
-
toInstantPositive
public static Instant toInstantPositive(long value)
Transforms the designatedlongto anInstant. If the designatedlongis not positive (<=0),nullwill be returned.- Parameters:
value- The positive value which to transform toInstant.- Returns:
- The designated
longvalue asInstantornullin case of0or a negative value.
-
toInstantPositiveOrZero
public static Instant toInstantPositiveOrZero(long value)
Transforms the designatedlongto anInstant. If the designatedlongis negative (<0),nullwill be returned.- Parameters:
value- The non-negative value which to transform toInstant.- Returns:
- The designated
longvalue asInstantornullin 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, anIOExceptionwill 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 isnullor empty,nullwill 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 isnullor empty,nullwill 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.ParameterExceptionto the corresponding (subclass of)de.aristaflow.ilm.utilParameterException.- Parameters:
pe- Thede.aristaflow.adept2.model.communication.webservice.ParameterExceptionwhich to transform to the corresponding (subclass of)de.aristaflow.ilm.utilParameterException.- Returns:
- The (subclass of)
de.aristaflow.ilm.utilParameterExceptioncorresponding 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
nullin case the configuration isnullor empty.
-
fromIlmNull
public static boolean fromIlmNull(Boolean value)
Transforms the designatedBooleanto a simpleboolean. If the designatedBooleanisnull,falsewill be returned.- Parameters:
value- The value which to transform toboolean.- Returns:
- The designated
booleanvalue orfalsein case ofnull.
-
fromIlmNull
public static int fromIlmNull(Integer value)
Transforms the designatedIntegerto a simpleint. If the designatedIntegerisnull,0will be returned.- Parameters:
value- The value which to transform toint.- Returns:
- The designated
intvalue or0in case ofnull.
-
fromIlmNull
public static int fromIlmNull(Integer value, int nullValue)
Transforms the designatedLongto a simplelong. If the designatedLongisnull, the designatednullValuewill be returned.- Parameters:
value- The value which to transform tolong.nullValue- The value to use in case the designatedvalueisnull.- Returns:
- The designated
longvalue or the designatednullValuein case ofnull.
-
fromIlmNull
public static long fromIlmNull(Long value)
Transforms the designatedLongto a simplelong. If the designatedLongisnull,0will be returned.- Parameters:
value- The value which to transform tolong.- Returns:
- The designated
longvalue or0in case ofnull.
-
fromIlmNull
public static long fromIlmNull(Long value, long nullValue)
Transforms the designatedLongto a simplelong. If the designatedLongisnull, the designatednullValuewill be returned.- Parameters:
value- The value which to transform tolong.nullValue- The value to use in case the designatedvalueisnull.- Returns:
- The designated
longvalue or the designatednullValuein case ofnull.
-
fromIlmInstant
public static long fromIlmInstant(Instant value)
Transforms the designatedInstantto a simplelong. If the designatedInstantisnull,0will be returned.- Parameters:
value- The value which to transform tolong.- Returns:
- The
longvalue of the designatedInstantor0in case ofnull.
-
fromIlmInstant
public static long fromIlmInstant(Instant value, long nullValue)
Transforms the designatedInstantto a simplelong. If the designatedInstantisnull, the designatednullValuewill be returned.- Parameters:
value- The value which to transform tolong.nullValue- The value to use in case the designatedvalueisnull.- Returns:
- The
longvalue of the designatedInstantor the designatednullValuein 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 newIlmExceptionthat is closest to the designated throwable. This is either a subclass ofIlmExceptioncorresponding to the designated throwable or aWrappingExceptionfor 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.
-
-