Class LongValue

java.lang.Object
org.apache.wicket.util.value.LongValue
All Implemented Interfaces:
Serializable, Comparable<LongValue>
Direct Known Subclasses:
Bytes

public class LongValue extends Object implements Comparable<LongValue>, Serializable
A base class based on the Java long primitive for value classes that want to implement standard operations on that value without the pain of aggregating a Long object.
Since:
1.2.6
Author:
Jonathan Locke
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final long
    the long value
  • Constructor Summary

    Constructors
    Constructor
    Description
    LongValue(long value)
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    final int
    Compares this Object to a given Object.
    final boolean
    equals(Object that)
    Tests for equality.
    final boolean
    greaterThan(long value)
    Compares this LongValue with a primitive long value.
    final boolean
    Compares this LongValue with another LongValue.
    final boolean
    greaterThanOrEqual(long value)
    Compares this LongValue with a primitive long value.
    final boolean
    Compares this LongValue with another LongValue.
    final int
    Returns the hash code for this Object.
    final boolean
    lessThan(long that)
    Compares this LongValue with a primitive long value.
    final boolean
    Compares this LongValue with another LongValue.
    final boolean
    lessThanOrEqual(long that)
    Compares this LongValue with a primitive long value.
    final boolean
    Compares this LongValue with another LongValue.
    static <T extends LongValue>
    T
    max(T lhs, T rhs)
    Returns the max of the two long values.
    static <T extends LongValue>
    T
    maxNullSafe(T lhs, T rhs)
    Null-safe version of max(T, T).
    static <T extends LongValue>
    T
    min(T lhs, T rhs)
    Returns the min of the two long values.
    Converts this LongValue to a String.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • value

      protected final long value
      the long value
  • Constructor Details

    • LongValue

      public LongValue(long value)
      Constructor.
      Parameters:
      value - the long value
  • Method Details

    • compareTo

      public final int compareTo(LongValue that)
      Compares this Object to a given Object.
      Specified by:
      compareTo in interface Comparable<LongValue>
      Parameters:
      that - the Object to compare with
      Returns:
      0 if equal, -1 if less than the given Object's value, or 1 if greater than given Object's value
    • equals

      public final boolean equals(Object that)
      Tests for equality.
      Overrides:
      equals in class Object
      Parameters:
      that - the Object to compare with
      Returns:
      true if this Object's value is equal to the given Object's value
    • greaterThan

      public final boolean greaterThan(long value)
      Compares this LongValue with a primitive long value.
      Parameters:
      value - the long value to compare with
      Returns:
      true if this LongValue is greater than the given long value
    • greaterThanOrEqual

      public final boolean greaterThanOrEqual(long value)
      Compares this LongValue with a primitive long value.
      Parameters:
      value - the long value to compare with
      Returns:
      true if this LongValue is greater than or equal to the given long value
    • greaterThan

      public final boolean greaterThan(LongValue that)
      Compares this LongValue with another LongValue.
      Parameters:
      that - the LongValue to compare with
      Returns:
      true if this LongValue is greater than the given LongValue
    • greaterThanOrEqual

      public final boolean greaterThanOrEqual(LongValue that)
      Compares this LongValue with another LongValue.
      Parameters:
      that - the LongValue to compare with
      Returns:
      true if this LongValue is greater than or equal to the given LongValue
    • hashCode

      public final int hashCode()
      Returns the hash code for this Object.
      Overrides:
      hashCode in class Object
      Returns:
      hash code for this Object
    • lessThan

      public final boolean lessThan(long that)
      Compares this LongValue with a primitive long value.
      Parameters:
      that - the long value to compare with
      Returns:
      true if this LongValue is less than the given long value
    • lessThanOrEqual

      public final boolean lessThanOrEqual(long that)
      Compares this LongValue with a primitive long value.
      Parameters:
      that - the long value to compare with
      Returns:
      true if this LongValue is less than or equal to the given long value
    • lessThan

      public final boolean lessThan(LongValue that)
      Compares this LongValue with another LongValue.
      Parameters:
      that - the LongValue value to compare with
      Returns:
      true if this LongValue is less than the given LongValue
    • lessThanOrEqual

      public final boolean lessThanOrEqual(LongValue that)
      Compares this LongValue with another LongValue.
      Parameters:
      that - the LongValue value to compare with
      Returns:
      true if this LongValue is less than or equal to the given LongValue
    • toString

      public String toString()
      Converts this LongValue to a String.
      Overrides:
      toString in class Object
      Returns:
      a String representation of this LongValue
    • min

      public static <T extends LongValue> T min(T lhs, T rhs)
      Returns the min of the two long values.
      Type Parameters:
      T -
      Parameters:
      lhs -
      rhs -
      Returns:
      min value
      Throws:
      IllegalArgumentException - if either argument is null
    • max

      public static <T extends LongValue> T max(T lhs, T rhs)
      Returns the max of the two long values.
      Type Parameters:
      T -
      Parameters:
      lhs -
      rhs -
      Returns:
      max value
      Throws:
      IllegalArgumentException - if either argument is null
    • maxNullSafe

      public static <T extends LongValue> T maxNullSafe(T lhs, T rhs)
      Null-safe version of max(T, T). Nulls are considered less then any concrete value.
      Type Parameters:
      T -
      Parameters:
      lhs -
      rhs -
      Returns:
      max of two values or null if they are both null