Class BasePrimitiveCoercer

All Implemented Interfaces:
ICoercer, IResolvingCoercer

public class BasePrimitiveCoercer extends StandardCoercer implements IResolvingCoercer
  • Field Details

  • Constructor Details

    • BasePrimitiveCoercer

      public BasePrimitiveCoercer(ICoercer nonPrimitiveCoercer, IType primitiveType, IType nonPrimitiveType)
  • Method Details

    • coerceValue

      public final Object coerceValue(IType typeToCoerceTo, Object value)
      Specified by:
      coerceValue in interface ICoercer
    • handlesNull

      public boolean handlesNull()
      Specified by:
      handlesNull in interface ICoercer
      Overrides:
      handlesNull in class StandardCoercer
      Returns:
      true if this coercer knows how to handle the null value.
    • resolveType

      public IType resolveType(IType target, IType source)
      Description copied from interface: IResolvingCoercer

      This method should produce a more appropriately parameterized type for the given target type for this coercion. This allows a coercion to communicate type information through the coercion process. An example is the MetaType-to-Class coercion. MetaType should be interpreted as Class from a type inference perspective, so this give the coercer a chance to let the compiler know so.

      If no more appropriate inference type exists, this method should return the source type.

      Specified by:
      resolveType in interface IResolvingCoercer
      Parameters:
      target - type
      Returns:
      a possibly more appropriately parameterized type or the source type if not
    • getPriority

      public int getPriority(IType to, IType from)
      Specified by:
      getPriority in interface ICoercer
      Overrides:
      getPriority in class StandardCoercer
      Returns:
      a value between 0 and MAX_PRIORITY, inclusive that indicates the priority of this coercer when resolving overloaded methods. Typically a coercer should return 0, but coercers that have a high affinity between the target and coerced type, such as primitives, can have higher priorities.
    • getPriorityOf

      public static int getPriorityOf(IType to, IType from)
    • distance

      private static int distance(IType from, IType to)
    • losesInformation

      public static int losesInformation(IType from, IType to)
    • getIndex

      private static int getIndex(IType type)
    • isInSameFamily

      private static boolean isInSameFamily(IType t1, IType t2)