Interface Conversion

All Known Implementing Classes:
DefaultConversion

public interface Conversion
Conversion from one type to another.
  • Method Summary

    Modifier and Type
    Method
    Description
    <S, T> boolean
    canConvert(Class<S> sourceTypeClass, Class<T> targetTypeClass)
    Returns whether the given source type can be converted to the given target type.
    <T> boolean
    canConvert(Object object, Class<T> targetTypeClass)
    Returns whether the given object can be converted to the given target type.
    <S, T> List<T>
    convert(Iterable<S> objectIterable, Class<S> sourceTypeClass, Class<T> targetTypeClass)
    Converts each object from a set to the target type.
    <S, T> List<T>
    convert(Iterable<S> objectIterable, Class<T> targetTypeClass)
    Converts each object from an iterable to the target type.
    <S, T> List<T>
    convert(List<S> objectList, Class<S> sourceTypeClass, Class<T> targetTypeClass)
    Converts each object from a list to the target type.
    <S, T> List<T>
    convert(List<S> objectList, Class<T> targetTypeClass)
    Converts each object from a list to the target type.
    <S, T> Set<T>
    convert(Set<S> objectList, Class<S> sourceTypeClass, Class<T> targetTypeClass)
    Converts each object from a set to the target type.
    <S, T> Set<T>
    convert(Set<S> objectList, Class<T> targetTypeClass)
    Converts each object from a set to the target type.
    <S, T> T
    convert(S object, Class<S> sourceTypeClass, Class<T> targetTypeClass)
    Converts an object to the target type.
    <S, T> T
    convert(S object, Class<T> targetTypeClass)
    Converts an object to the target type.
  • Method Details

    • canConvert

      <S, T> boolean canConvert(Class<S> sourceTypeClass, Class<T> targetTypeClass)
      Returns whether the given source type can be converted to the given target type.
      Type Parameters:
      S - The source generic type
      T - The target generic type
      Parameters:
      sourceTypeClass - The source type class
      targetTypeClass - The target type class
      Returns:
      true if conversion is possible, otherwise, false
    • canConvert

      <T> boolean canConvert(Object object, Class<T> targetTypeClass)
      Returns whether the given object can be converted to the given target type.
      Type Parameters:
      T - The target generic type
      Parameters:
      object - The source object
      targetTypeClass - The target type class
      Returns:
      true if conversion is possible, otherwise, false
    • convert

      <S, T> T convert(S object, Class<T> targetTypeClass)
      Converts an object to the target type.
      Type Parameters:
      S - The source generic type
      T - The target generic type
      Parameters:
      object - The object to convert
      targetTypeClass - The target type class
      Returns:
      converted object
      Throws:
      ConversionException.ConverterDoesNotExist - If the needed converter does not exist
    • convert

      <S, T> T convert(S object, Class<S> sourceTypeClass, Class<T> targetTypeClass)
      Converts an object to the target type.
      Type Parameters:
      S - The source generic type
      T - The target generic type
      Parameters:
      object - The object to convert
      sourceTypeClass - The source type class
      targetTypeClass - The target type class
      Returns:
      converted object
      Throws:
      ConversionException.ConverterDoesNotExist - If the needed converter does not exist
    • convert

      <S, T> List<T> convert(Iterable<S> objectIterable, Class<T> targetTypeClass)
      Converts each object from an iterable to the target type.
      Type Parameters:
      S - The source generic type
      T - The target generic type
      Parameters:
      objectIterable - The iterable of objects to convert
      targetTypeClass - The target type class
      Returns:
      converted collection of objects
      Throws:
      ConversionException.ConverterDoesNotExist - If the needed converter does not exist
    • convert

      <S, T> List<T> convert(Iterable<S> objectIterable, Class<S> sourceTypeClass, Class<T> targetTypeClass)
      Converts each object from a set to the target type.
      Type Parameters:
      S - The source generic type
      T - The target generic type
      Parameters:
      objectIterable - The iterable of objects to convert
      sourceTypeClass - The source type class
      targetTypeClass - The target type class
      Returns:
      converted collection of objects
      Throws:
      ConversionException.ConverterDoesNotExist - If the needed converter does not exist
    • convert

      <S, T> List<T> convert(List<S> objectList, Class<T> targetTypeClass)
      Converts each object from a list to the target type.
      Type Parameters:
      S - The source generic type
      T - The target generic type
      Parameters:
      objectList - The list of objects to convert
      targetTypeClass - The target type class
      Returns:
      converted collection of objects
      Throws:
      ConversionException.ConverterDoesNotExist - If the needed converter does not exist
    • convert

      <S, T> List<T> convert(List<S> objectList, Class<S> sourceTypeClass, Class<T> targetTypeClass)
      Converts each object from a list to the target type.
      Type Parameters:
      S - The source generic type
      T - The target generic type
      Parameters:
      objectList - The list of objects to convert
      sourceTypeClass - The source type class
      targetTypeClass - The target type class
      Returns:
      converted collection of objects
      Throws:
      ConversionException.ConverterDoesNotExist - If the needed converter does not exist
    • convert

      <S, T> Set<T> convert(Set<S> objectList, Class<T> targetTypeClass)
      Converts each object from a set to the target type.
      Type Parameters:
      S - The source generic type
      T - The target generic type
      Parameters:
      objectList - The set of objects to convert
      targetTypeClass - The target type class
      Returns:
      converted collection of objects
      Throws:
      ConversionException.ConverterDoesNotExist - If the needed converter does not exist
    • convert

      <S, T> Set<T> convert(Set<S> objectList, Class<S> sourceTypeClass, Class<T> targetTypeClass)
      Converts each object from a set to the target type.
      Type Parameters:
      S - The source generic type
      T - The target generic type
      Parameters:
      objectList - The set of objects to convert
      sourceTypeClass - The source type class
      targetTypeClass - The target type class
      Returns:
      converted collection of objects
      Throws:
      ConversionException.ConverterDoesNotExist - If the needed converter does not exist