Class Utils


  • public abstract class Utils
    extends java.lang.Object
    Utilities class.
    Author:
    Mahmoud Ben Hassine ([email protected])
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void checkArgument​(boolean assertion, java.lang.String message)  
      static void checkNotNull​(java.lang.Object argument, java.lang.String argumentName)  
      static <P> java.util.List<P> extractPayloads​(java.util.List<? extends Record<P>> records)
      Extract the payload form each record.
      static java.lang.String formatDuration​(java.time.Duration duration)  
      static java.lang.String formatErrorThreshold​(long errorThreshold)  
      static java.lang.String formatTime​(java.time.LocalDateTime time)  
      static java.lang.Class<?> getGenericTypeNameFromTypeConverter​(TypeConverter<?,​?> typeConverter, int genericTypeIndex)
      This method is used to get the generic parameter type (source or target) from a TypeConverter.
      static java.util.Map<java.lang.String,​java.lang.reflect.Method> getGetters​(java.lang.Class<?> type)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • LINE_SEPARATOR

        public static final java.lang.String LINE_SEPARATOR
      • FILE_SEPARATOR

        public static final java.lang.String FILE_SEPARATOR
      • JAVA_IO_TMPDIR

        public static final java.lang.String JAVA_IO_TMPDIR
    • Method Detail

      • checkNotNull

        public static void checkNotNull​(java.lang.Object argument,
                                        java.lang.String argumentName)
      • checkArgument

        public static void checkArgument​(boolean assertion,
                                         java.lang.String message)
      • getGetters

        public static java.util.Map<java.lang.String,​java.lang.reflect.Method> getGetters​(java.lang.Class<?> type)
                                                                                         throws java.beans.IntrospectionException
        Throws:
        java.beans.IntrospectionException
      • formatTime

        public static java.lang.String formatTime​(java.time.LocalDateTime time)
      • formatDuration

        public static java.lang.String formatDuration​(java.time.Duration duration)
      • formatErrorThreshold

        public static java.lang.String formatErrorThreshold​(long errorThreshold)
      • extractPayloads

        public static <P> java.util.List<P> extractPayloads​(java.util.List<? extends Record<P>> records)
        Extract the payload form each record.
        Type Parameters:
        P - the type of payload
        Parameters:
        records - the list of records
        Returns:
        the list of payloads
      • getGenericTypeNameFromTypeConverter

        public static java.lang.Class<?> getGenericTypeNameFromTypeConverter​(TypeConverter<?,​?> typeConverter,
                                                                             int genericTypeIndex)
                                                                      throws java.lang.Exception
        This method is used to get the generic parameter type (source or target) from a TypeConverter. This is used in:
        • ObjectMapper: when registering TypeConverter from String to ? (for parsing)
        • BeanFieldExtractor: when registering TypeConverter from ? to String (for formatting)
        Parameters:
        typeConverter - to introspect
        genericTypeIndex - 0 or 1 depending on what we are looking for (source or target type)
        Returns:
        The class name of the generic parameter type
        Throws:
        java.lang.Exception - when unable to get generic parameter type