Interface TypeRules

All Known Implementing Classes:
TypeSet

public interface TypeRules

Minimal TypeSet interface for use when only testing of types is required/allowed.

  • Method Summary

    Modifier and Type
    Method
    Description
    void
    debug(String msg, Object... args)
    Print some debug info to the TypeRules logger - this should be decorated with some extra context that helps put a particular rule checks logging more easily interpreted
    findEquivalenceCoercer(Type sourceType, Type targetType)
    Search through the list of EquivalenceRules and find the first one that can safely coerce a value from the source type to the target type.
    default boolean
    isAssignable(Type sourceType, Type targetType)
     
    testVariance(Type sourceType, Type targetType)
    Search through the list of VarianceRules to determine whether a value of sourceType can be assigned to a receiver of targetType
  • Method Details

    • findEquivalenceCoercer

      Optional<Coercer> findEquivalenceCoercer(Type sourceType, Type targetType)

      Search through the list of EquivalenceRules and find the first one that can safely coerce a value from the source type to the target type. This will return an object that will allow the source type to be safely converted to the target type.

      Parameters:
      sourceType - the type of the value that is being assigned to something. type
      targetType - the receiving type
      Returns:
      a Coercer, or empty if none could be found.
    • testVariance

      Variance testVariance(Type sourceType, Type targetType)

      Search through the list of VarianceRules to determine whether a value of sourceType can be assigned to a receiver of targetType

      Parameters:
      sourceType - the type of the value that is being assigned to something.
      targetType - the receiving type
      Returns:
      a determined variance calculation, or Variance.UNKNOWN if it couldn't be determined. You should assume invariance if unknown is returned.
    • isAssignable

      default boolean isAssignable(Type sourceType, Type targetType)
      Returns:
      true if values of sourceType can be assigned to values of targetType. Note that this test is not commutable, i.e. isAssignable(lhs, rhs) is not equivalent to isAssignable(rhs, lhs).
    • debug

      void debug(String msg, Object... args)

      Print some debug info to the TypeRules logger - this should be decorated with some extra context that helps put a particular rule checks logging more easily interpreted