Interface TypeConverter

All Known Implementing Classes:
DefaultTypeConverter

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

    Modifier and Type
    Method
    Description
    <T> T
    convert(Object object, Class<T> type)
    Converts an object from one type to another.
  • Method Details

    • convert

      <T> T convert(Object object, Class<T> type) throws 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:
      NullPointerException - if the given object is null.
      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.