org.jcoderz.commons.test
Class RestrictedLong

java.lang.Object
  extended by org.jcoderz.commons.test.RestrictedLong
All Implemented Interfaces:
Serializable, Comparable, RestrictedLong, StrongType

public final class RestrictedLong
extends Object
implements Serializable, RestrictedLong, Comparable

Holds the RestrictedLong.

 long[15..255].
 
Instances of this class are immutable.

This class implements the Comparable interface based on the numeric order of its instances.

Author:
generated via stylesheet
See Also:
Serialized Form

Field Summary
static long MAX_VALUE
          The maximum value of a RestrictedLong (255).
static long MIN_VALUE
          The minimum value of a RestrictedLong (15).
static String TYPE_NAME
          RestrictedLong - the name of this type as string constant.
 
Method Summary
 int compareTo(Object o)
          Compares this RestrictedLong with an other.
 boolean equals(Object obj)
          
static RestrictedLong fromLong(long id)
          Construct a RestrictedLong object from its long representation.
static RestrictedLong fromLong(Long id)
          Construct a RestrictedLong object from its Long representation.
static RestrictedLong fromString(String s)
          Construct a RestrictedLong object from its string representation.
 int hashCode()
          
static RestrictedLong random()
          Generates a random RestrictedLong object.
 long toLong()
          Returns the long representation of this RestrictedLong object.
 Long toLongObject()
          Returns the Long representation of this RestrictedLong object.
 String toString()
          
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

TYPE_NAME

public static final String TYPE_NAME
RestrictedLong - the name of this type as string constant.

See Also:
Constant Field Values

MIN_VALUE

public static final long MIN_VALUE
The minimum value of a RestrictedLong (15).

See Also:
Constant Field Values

MAX_VALUE

public static final long MAX_VALUE
The maximum value of a RestrictedLong (255).

See Also:
Constant Field Values
Method Detail

fromLong

public static RestrictedLong fromLong(long id)
                               throws ArgumentMalformedException
Construct a RestrictedLong object from its long representation.

Parameters:
id - the long representation of the RestrictedLong
Returns:
the RestrictedLong object represented by the given long
Throws:
ArgumentMalformedException - If the given long id violates the restriction of the type RestrictedLong.
ArgumentMinValueViolationException - If the value of the given long id is below MIN_VALUE.
ArgumentMaxValueViolationException - If the value of the given long id is above MAX_VALUE.

fromString

public static RestrictedLong fromString(String s)
                                 throws ArgumentMalformedException
Construct a RestrictedLong object from its string representation.

Parameters:
s - the string representation of the RestrictedLong
Returns:
the RestrictedLong object represented by the given string
Throws:
ArgumentMalformedException - If the given string s violates the restriction of the type RestrictedLong.
ArgumentMinValueViolationException - If the value of the given long id is below MIN_VALUE.
ArgumentMaxValueViolationException - If the value of the given long id is above MAX_VALUE.

fromLong

public static RestrictedLong fromLong(Long id)
                               throws ArgumentMalformedException
Construct a RestrictedLong object from its Long representation.

Parameters:
id - the Long representation of the RestrictedLong
Returns:
the RestrictedLong object represented by the given Long
Throws:
ArgumentMalformedException - If the given Long id is null or violates the restriction of the type RestrictedLong.
ArgumentMinValueViolationException - If the value of the given long id is below MIN_VALUE.
ArgumentMaxValueViolationException - If the value of the given long id is above MAX_VALUE.

random

public static RestrictedLong random()
Generates a random RestrictedLong object.

Returns:
a random RestrictedLong object.

toLong

public long toLong()
Returns the long representation of this RestrictedLong object.

Specified by:
toLong in interface RestrictedLong
Returns:
the long representation of this RestrictedLong object.

toLongObject

public Long toLongObject()
Returns the Long representation of this RestrictedLong object.

Specified by:
toLongObject in interface RestrictedLong
Returns:
the Long representation of this RestrictedLong object.

toString

public String toString()

Overrides:
toString in class Object

equals

public boolean equals(Object obj)

Overrides:
equals in class Object

hashCode

public int hashCode()

Overrides:
hashCode in class Object

compareTo

public int compareTo(Object o)
Compares this RestrictedLong with an other. The order is based on the numeric order of the of the compared instances.

Specified by:
compareTo in interface Comparable
Returns:
a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
Throws:
ClassCastException - if the specified object's type prevents it from being compared to this Object.
See Also:
Long.compareTo(Object)


Copyright 2007 The jCoderZ Project.