Class Transformation


  • public class Transformation
    extends Object
    • Constructor Detail

      • Transformation

        public Transformation()
    • Method Detail

      • toIlmPositive

        public static Long toIlmPositive​(long value)
        Transforms the designated long to Long. If the designated long is not positive (<=0), null will be returned.
        Parameters:
        value - The positive value which to transform to Long.
        Returns:
        The designated long value or null in case of 0 or a negative value.
      • toInstantPositive

        public static Instant toInstantPositive​(long value)
        Transforms the designated long to an Instant. If the designated long is not positive (<=0), null will be returned.
        Parameters:
        value - The positive value which to transform to Instant.
        Returns:
        The designated long value as Instant or null in case of 0 or a negative value.
      • toInstantPositiveOrZero

        public static Instant toInstantPositiveOrZero​(long value)
        Transforms the designated long to an Instant. If the designated long is negative (<0), null will be returned.
        Parameters:
        value - The non-negative value which to transform to Instant.
        Returns:
        The designated long value as Instant or null 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, an IOException 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 is null 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 or null.
        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 is null 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 or null.
        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 designated de.aristaflow.adept2.model.communication.webservice.ParameterException to the corresponding (subclass of) de.aristaflow.ilm.utilParameterException.
        Parameters:
        pe - The de.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 designated de.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 using Object.toString().
        Parameters:
        conf - The configuration which to transform to a string map. This may be null.
        Returns:
        A string map containing the entries of the designated configuration or null in case the configuration is null or empty.
      • fromIlmNull

        public static boolean fromIlmNull​(Boolean value)
        Transforms the designated Boolean to a simple boolean. If the designated Boolean is null, false will be returned.
        Parameters:
        value - The value which to transform to boolean.
        Returns:
        The designated boolean value or false in case of null.
      • fromIlmNull

        public static int fromIlmNull​(Integer value)
        Transforms the designated Integer to a simple int. If the designated Integer is null, 0 will be returned.
        Parameters:
        value - The value which to transform to int.
        Returns:
        The designated int value or 0 in case of null.
      • fromIlmNull

        public static int fromIlmNull​(Integer value,
                                      int nullValue)
        Transforms the designated Long to a simple long. If the designated Long is null, the designated nullValue will be returned.
        Parameters:
        value - The value which to transform to long.
        nullValue - The value to use in case the designated value is null.
        Returns:
        The designated long value or the designated nullValue in case of null.
      • fromIlmNull

        public static long fromIlmNull​(Long value)
        Transforms the designated Long to a simple long. If the designated Long is null, 0 will be returned.
        Parameters:
        value - The value which to transform to long.
        Returns:
        The designated long value or 0 in case of null.
      • fromIlmNull

        public static long fromIlmNull​(Long value,
                                       long nullValue)
        Transforms the designated Long to a simple long. If the designated Long is null, the designated nullValue will be returned.
        Parameters:
        value - The value which to transform to long.
        nullValue - The value to use in case the designated value is null.
        Returns:
        The designated long value or the designated nullValue in case of null.
      • fromIlmInstant

        public static long fromIlmInstant​(Instant value)
        Transforms the designated Instant to a simple long. If the designated Instant is null, 0 will be returned.
        Parameters:
        value - The value which to transform to long.
        Returns:
        The long value of the designated Instant or 0 in case of null.
      • fromIlmInstant

        public static long fromIlmInstant​(Instant value,
                                          long nullValue)
        Transforms the designated Instant to a simple long. If the designated Instant is null, the designated nullValue will be returned.
        Parameters:
        value - The value which to transform to long.
        nullValue - The value to use in case the designated value is null.
        Returns:
        The long value of the designated Instant or the designated nullValue in case of null.
      • 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 new IlmException that is closest to the designated throwable. This is either a subclass of IlmException corresponding to the designated throwable or a WrappingException 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.
      • convertWildcardsToSql

        public static String convertWildcardsToSql​(String likeString)