Class ReflectionStringConverter<T>

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.Class<T> cls
      The converted class.
      private java.lang.reflect.Method toString
      Conversion to a string.
    • Constructor Summary

      Constructors 
      Constructor Description
      ReflectionStringConverter​(java.lang.Class<T> cls, java.lang.reflect.Method toString)
      Creates an instance using two methods.
    • Field Detail

      • cls

        private final java.lang.Class<T> cls
        The converted class.
      • toString

        private final java.lang.reflect.Method toString
        Conversion to a string.
    • Constructor Detail

      • ReflectionStringConverter

        ReflectionStringConverter​(java.lang.Class<T> cls,
                                  java.lang.reflect.Method toString)
        Creates an instance using two methods.
        Parameters:
        cls - the class this converts for, not null
        toString - the toString method, not null
        Throws:
        java.lang.RuntimeException - (or subclass) if the method signatures are invalid
    • Method Detail

      • convertToString

        public java.lang.String convertToString​(T object)
        Converts the object to a String.
        Specified by:
        convertToString in interface ToStringConverter<T>
        Parameters:
        object - the object to convert, not null
        Returns:
        the converted string, may be null but generally not
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object