Enum Class Variance

java.lang.Object
java.lang.Enum<Variance>
nz.org.riskscape.engine.types.varule.Variance
All Implemented Interfaces:
Serializable, Comparable<Variance>, Constable

public enum Variance extends Enum<Variance>

Represents the result of a TypeSet.testVariance(nz.org.riskscape.engine.types.Type,nz.org.riskscape.engine.types.Type)

NB The terminology is borrowed loosely from computer science, but It is doubtful that it matches any of the strict definitions that exist in other strictly typed, polymorphic, genericized languages.

  • Enum Constant Details

    • UNKNOWN

      public static final Variance UNKNOWN

      This rule is not applicable for the given types - not a yes or a no. Try again, caller.

    • INVARIANT

      public static final Variance INVARIANT

      The rule says that values of source type can not be safely assigned to the target.

    • COVARIANT

      public static final Variance COVARIANT

      The rule says that values of source type can safely be assigned to the target, even though they are not an exact match. This must mean that the underlying java types are themselves co-variant.

    • EQUAL

      public static final Variance EQUAL

      The rule says that values of source type can safely be assigned to the target, and appear to be an exact match. TODO - should this mean that source.equals(target) = true?

  • Method Details

    • values

      public static Variance[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static Variance valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • min

      public static Variance min(Variance a, Variance b)
      Returns:
      the lowest variance from those given. This is like saying of these two possible assignments, this is the worst case