Package gw.lang

Interface IDimension<S extends IDimension<S,​T>,​T extends java.lang.Number>

  • All Superinterfaces:
    java.lang.Comparable<S>

    public interface IDimension<S extends IDimension<S,​T>,​T extends java.lang.Number>
    extends java.lang.Comparable<S>
    • Method Detail

      • toNumber

        T toNumber()
        The Gosu runtime calls this method when performing default operations. For instance, when adding two of the same dimension types, Gosu calls this method on each operand, adds the numbers, and then calls fromNumber() for the result.
        Returns:
        the number of units for this dimension instance.
      • toBaseNumber

        default T toBaseNumber()
      • fromNumber

        S fromNumber​(T units)
        Returns a separate instance of this type with the given number of units.

        The Gosu runtime calls this method when performing default operations. For instance, when adding two of the same dimension types, Gosu calls toNumber() on each operand, adds the numbers, and then calls fromNumber() for the result.

        Returns:
        a separate instance of this type given the number of units.
      • numberType

        java.lang.Class<T> numberType()
        Returns:
        The static Number derivation for this class. Must be the same as the T parameter. Note this is only useful in Java where the type is lost at runtime due to type erasure.