Package org.apache.torque.om

## Class NumberKey

- java.lang.Object
- - org.apache.torque.om.ObjectKey<T>
  - - org.apache.torque.om.SimpleKey<BigDecimal>
    - - org.apache.torque.om.NumberKey

- All Implemented Interfaces:
    `Serializable`, `Comparable<Object>`

      public class NumberKey
      extends SimpleKey<BigDecimal>

  This class can be used as an ObjectKey to uniquely identify an object within an application where the id consists of a single entity such a GUID or the value of a db row's primary key.
  Version:
    $Id: NumberKey.java 1849379 2018-12-20 12:33:43Z tv $
  Author:
    John McNally, Stephen Haberman, Runako Godfrey
  See Also:
    Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `NumberKey()` | Initializes the internal key value to `null`.
    `NumberKey​(double key)` | Creates a NumberKey equivalent to `key`.
    `NumberKey​(int key)` | Creates a NumberKey equivalent to `key`.
    `NumberKey​(long key)` | Creates a NumberKey equivalent to `key`.
    `NumberKey​(Number key)` | Creates a NumberKey equivalent to `key`.
    `NumberKey​(String key)` | Creates an NumberKey and set its internal representation
    `NumberKey​(BigDecimal key)` | Creates an NumberKey and set its internal representation
    `NumberKey​(NumberKey key)` | Creates a NumberKey that is equivalent to key.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `byte` | `byteValue()` | Returns the value of this NumberKey as a byte.
    `int` | `compareTo​(Object o)` | Implements the compareTo method.
    `double` | `doubleValue()` | Returns the value of this NumberKey as a double.
    `float` | `floatValue()` | Returns the value of this NumberKey as a float.
    `int` | `getJdbcType()` | Returns the JDBC type of the key as defined in `java.sql.Types`.
    `int` | `intValue()` | Returns the value of this NumberKey as an int.
    `long` | `longValue()` | Returns the value of this NumberKey as a long.
    `void` | `setValue​(String key)` | Sets the internal representation using a String representation of a number.
    `short` | `shortValue()` | Returns the value of this NumberKey as a short.

    - ### Methods inherited from class org.apache.torque.om.SimpleKey

      `keyFor, keyFor, keyFor, keyFor, keyFor, keyFor, keyFor, keyFor, keyFor, keyFor, keyFor`

    - ### Methods inherited from class org.apache.torque.om.ObjectKey

      `appendTo, equals, getValue, hashCode, setValue, setValue, toString`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### NumberKey

          public NumberKey()

      Initializes the internal key value to `null`.

    - #### NumberKey

          public NumberKey​(String key)

      Creates an NumberKey and set its internal representation
      Parameters:
        `key` - the key value as String

    - #### NumberKey

          public NumberKey​(BigDecimal key)

      Creates an NumberKey and set its internal representation
      Parameters:
        `key` - the key value

    - #### NumberKey

          public NumberKey​(NumberKey key)

      Creates a NumberKey that is equivalent to key.
      Parameters:
        `key` - the key value

    - #### NumberKey

          public NumberKey​(long key)

      Creates a NumberKey equivalent to `key`.
      Parameters:
        `key` - the key value

    - #### NumberKey

          public NumberKey​(double key)

      Creates a NumberKey equivalent to `key`.
      Parameters:
        `key` - the key value

    - #### NumberKey

          public NumberKey​(int key)

      Creates a NumberKey equivalent to `key`. Convenience only.
      Parameters:
        `key` - the key value

    - #### NumberKey

          public NumberKey​(Number key)

      Creates a NumberKey equivalent to `key`. Convenience only.
      Parameters:
        `key` - the key value

  - ### Method Detail

    - #### setValue

          public void setValue​(String key)

      Sets the internal representation using a String representation of a number.
      Parameters:
        `key` - the key value
      Throws:
        `NumberFormatException` - if key is not a valid number

    - #### getJdbcType

          public int getJdbcType()

      Returns the JDBC type of the key as defined in `java.sql.Types`.
      Specified by:
        `getJdbcType` in class `ObjectKey<BigDecimal>`
      Returns:
        `Types.NUMERIC`.

    - #### compareTo

          public int compareTo​(Object o)

      Description copied from class: `ObjectKey`
      Implements the compareTo method.
      Specified by:
        `compareTo` in interface `Comparable<Object>`
      Overrides:
        `compareTo` in class `ObjectKey<BigDecimal>`
      Parameters:
        `o` - the comparison value
      Returns:
        a numeric comparison of the two values

    - #### byteValue

          public byte byteValue()

      Returns the value of this NumberKey as a byte. This value is subject to the conversion rules set out in `Number.byteValue()`
      Returns:
        the NumberKey converted to a byte

    - #### intValue

          public int intValue()

      Returns the value of this NumberKey as an int. This value is subject to the conversion rules set out in `BigDecimal.intValue()`, importantly any fractional part will be discarded and if the underlying value is too big to fit in an int, only the low-order 32 bits are returned. Note that this conversion can lose information about the overall magnitude and precision of the NumberKey value as well as return a result with the opposite sign.
      Returns:
        the NumberKey converted to an int

    - #### shortValue

          public short shortValue()

      Returns the value of this NumberKey as a short. This value is subject to the conversion rules set out in `BigDecimal.intValue()`, importantly any fractional part will be discarded and if the underlying value is too big to fit in a long, only the low-order 64 bits are returned. Note that this conversion can lose information about the overall magnitude and precision of the NumberKey value as well as return a result with the opposite sign.
      Returns:
        the NumberKey converted to a short

    - #### longValue

          public long longValue()

      Returns the value of this NumberKey as a long. This value is subject to the conversion rules set out in `BigDecimal.intValue()`
      Returns:
        the NumberKey converted to a long

    - #### floatValue

          public float floatValue()

      Returns the value of this NumberKey as a float. This value is subject to the conversion rules set out in `BigDecimal.floatValue()`, most importantly if the underlying value has too great a magnitude to represent as a float, it will be converted to Float.NEGATIVE_INFINITY or Float.POSITIVE_INFINITY as appropriate.
      Returns:
        the NumberKey converted to a float

    - #### doubleValue

          public double doubleValue()

      Returns the value of this NumberKey as a double. This value is subject to the conversion rules set out in `BigDecimal.doubleValue()`, most importantly if the underlying value has too great a magnitude to represent as a double, it will be converted to Double.NEGATIVE_INFINITY or Double.POSITIVE_INFINITY as appropriate.
      Returns:
        the NumberKey converted to a double