Interface TypeConverter

  • All Known Implementing Classes:
    DefaultTypeConverter

    public interface TypeConverter
    Converts an object from one type to another.
    Author:
    Garret Wilson
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      <T> T convert​(java.lang.Object object, java.lang.Class<T> type)
      Converts an object from one type to another.
    • Method Detail

      • convert

        <T> T convert​(java.lang.Object object,
                      java.lang.Class<T> type)
               throws java.lang.IllegalArgumentException
        Converts an object from one type to another. If the object is already of the correct type, no action occurs.
        Type Parameters:
        T - The type of object required.
        Parameters:
        object - The object to convert.
        type - The class representing required type of the object.
        Returns:
        The object as the required type, or null if the object cannot be converted to the required type.
        Throws:
        java.lang.NullPointerException - if the given object is null.
        java.lang.IllegalArgumentException - if the given object should be able to be converted to the required type but something about its state, format, or contents prevented the conversion.