Class TypeConvertible<F,T>

java.lang.Object
org.apache.camel.spi.TypeConvertible<F,T>
Type Parameters:
F - The "from" type
T - The "to" type.

public final class TypeConvertible<F,T> extends Object
Holds a type convertible pair. That is, consider 2 types defined as F and T, it defines that F can be converted to T.
  • Constructor Summary

    Constructors
    Constructor
    Description
    TypeConvertible(Class<F> from, Class<T> to)
    Constructs a new type convertible pair.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
     
    Gets the class instance that defines the "from" type (that is: Class<F>.class)
    Gets the class instance that defines the "to" type (that is: Class<F>.class).
    int
     
    boolean
    Tests whether the types defined in this type convertable pair are assignable from another type convertable pair
    boolean
    Tests whether there is a conversion match from this TypeConvertible to the given TypeConvertible.
    boolean
    Tests whether there is a conversion match from this TypeConvertible to the given TypeConvertible when the "to" type of the tested TypeConvertible is a primitive type.
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • TypeConvertible

      public TypeConvertible(Class<F> from, Class<T> to)
      Constructs a new type convertible pair. This is likely only used by core camel code and auto-generated bulk loaders. This is an internal API and not meant for end users.
      Parameters:
      from - The class instance that defines the "from" type (that is: Class<F>.class). Must NOT be null.
      to - The class instance that defines the "to" type (that is: Class<F>.class). Must NOT be null.
  • Method Details

    • matches

      public boolean matches(TypeConvertible<?,?> that)
      Tests whether there is a conversion match from this TypeConvertible to the given TypeConvertible. For instance, consider 2 TypeConvertibles defined as "tc1{from: Number.class, to: String.class}" and "tc2{from: Integer.class, to: String.class}", it traverses the type hierarchy of the "from" class to determine if it, or any of its superclasses or any of its interfaces match with the "from" type of this instance.
      Parameters:
      that - the TypeConvertible being tested against this instance
      Returns:
      true if there is a conversion match between the give TypeConvertible and this instance.
    • matchesPrimitive

      public boolean matchesPrimitive(TypeConvertible<?,?> that)
      Tests whether there is a conversion match from this TypeConvertible to the given TypeConvertible when the "to" type of the tested TypeConvertible is a primitive type. See matches(TypeConvertible) for details.
      Parameters:
      that - the TypeConvertible being tested against this instance
      Returns:
      true if there is a conversion match between the give TypeConvertible and this instance.
    • isAssignableMatch

      public boolean isAssignableMatch(TypeConvertible<?,?> that)
      Tests whether the types defined in this type convertable pair are assignable from another type convertable pair
      Parameters:
      that - the type convertible pair to test
      Returns:
      true if the types in this instance are assignable from the respective types in the given type convertible
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • getFrom

      public Class<F> getFrom()
      Gets the class instance that defines the "from" type (that is: Class<F>.class)
      Returns:
      the "from" class instance
    • getTo

      public Class<T> getTo()
      Gets the class instance that defines the "to" type (that is: Class<F>.class).
      Returns:
      the "to" class instance
    • toString

      public String toString()
      Overrides:
      toString in class Object