Class TypeConverterRuleAnySourceFixedDestination<DST>

java.lang.Object
com.helger.commons.typeconvert.rule.AbstractTypeConverterRule<Object,DST>
com.helger.commons.typeconvert.rule.TypeConverterRuleAnySourceFixedDestination<DST>
Type Parameters:
DST - Destination type
All Implemented Interfaces:
ITypeConverter<Object,DST>, ITypeConverterRule<Object,DST>, Function<Object,DST>

public class TypeConverterRuleAnySourceFixedDestination<DST> extends AbstractTypeConverterRule<Object,DST>
Type converter than can convert from a base source class to a destination class. Example from Object.class to String.class
Author:
Philip Helger
  • Constructor Details

  • Method Details

    • canConvert

      public final boolean canConvert(@Nonnull Class<?> aSrcClass, @Nonnull Class<?> aDstClass)
      Description copied from interface: ITypeConverterRule
      Check if this converter can handle the conversion from the passed source to the passed destination class. Note: as this method is called for every type conversion for which no exact converters are present, the implementation of this method should be as efficient as possible.
      Parameters:
      aSrcClass - Source class to convert from. Never null.
      aDstClass - Destination class to convert to. Never null.
      Returns:
      true if conversion is possible, false otherwise.
    • getDestinationClass

      @Nonnull public final Class<?> getDestinationClass()
    • apply

      @Nullable public DST apply(@Nonnull Object aSource)
      Description copied from interface: ITypeConverter
      Convert the passed source object to the destination type.
      Parameters:
      aSource - The source object to be converted. Cannot be null because the type converter already filters null values!
      Returns:
      The converted value. May be null.
    • toString

      public String toString()
      Overrides:
      toString in class AbstractTypeConverterRule<Object,DST>