Class NumberOnly

java.lang.Object
java.lang.Number
org.soliscode.test.interfaces.NumberOnly
All Implemented Interfaces:
Serializable

public class NumberOnly extends Number

The NumberOnly lass wraps any object and only exposes the methods on the Number interface. This is used for testing a class or method implementation that operates on a Number without any optimizations for the instantiated class or any other implemented interfaces.

Objects of this class should be created using the Interfaces utility class:

    Integer i = 3;
    Number n = Interfaces.numberOnly(i);
Since:
1.0
Author:
evanbergstrom
See Also:
  • Constructor Details

    • NumberOnly

      public NumberOnly(@NotNull @NotNull Number number)
      Creates an instance of NumberOnly that wraps an instance of Number and narrows the interface to only the methods available in the Number interface.
      Parameters:
      number - an instance of number to wrap.
  • Method Details

    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • intValue

      public int intValue()
      Specified by:
      intValue in class Number
    • longValue

      public long longValue()
      Specified by:
      longValue in class Number
    • floatValue

      public float floatValue()
      Specified by:
      floatValue in class Number
    • doubleValue

      public double doubleValue()
      Specified by:
      doubleValue in class Number
    • listOf

      public static List<NumberOnly> listOf(int... values)
      Creates a List of NumberOnly values based upon a list of integer constants.
      Parameters:
      values - The integer values.
      Returns:
      a list of NumberOnly values.