org.apache.wicket.util.value
Class LongValue

java.lang.Object
  extended by org.apache.wicket.util.value.LongValue
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<LongValue>
Direct Known Subclasses:
Bytes, Duration, Time, TimeOfDay

public class LongValue
extends java.lang.Object
implements java.lang.Comparable<LongValue>, java.io.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:
Serialized Form

Field Summary
protected  long value
          the long value
 
Constructor Summary
LongValue(long value)
          Constructor.
 
Method Summary
 int compareTo(LongValue that)
          Compares this Object to a given Object.
 boolean equals(java.lang.Object that)
          Tests for equality.
 boolean greaterThan(long value)
          Compares this LongValue with a primitive long value.
 boolean greaterThan(LongValue that)
          Compares this LongValue with another LongValue.
 boolean greaterThanOrEqual(long value)
          Compares this LongValue with a primitive long value.
 boolean greaterThanOrEqual(LongValue that)
          Compares this LongValue with another LongValue.
 int hashCode()
          Returns the hash code for this Object.
 boolean lessThan(long that)
          Compares this LongValue with a primitive long value.
 boolean lessThan(LongValue that)
          Compares this LongValue with another LongValue.
 boolean lessThanOrEqual(long that)
          Compares this LongValue with a primitive long value.
 boolean lessThanOrEqual(LongValue that)
          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).
 java.lang.String toString()
          Converts this LongValue to a String.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

value

protected final long value
the long value

Constructor Detail

LongValue

public LongValue(long value)
Constructor.

Parameters:
value - the long value
Method Detail

compareTo

public final int compareTo(LongValue that)
Compares this Object to a given Object.

Specified by:
compareTo in interface java.lang.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(java.lang.Object that)
Tests for equality.

Overrides:
equals in class java.lang.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 java.lang.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 java.lang.String toString()
Converts this LongValue to a String.

Overrides:
toString in class java.lang.Object
Returns:
a String representation of this LongValue

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:
java.lang.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


Copyright © 2006-2011 Apache Software Foundation. All Rights Reserved.