org.apache.commons.id.serial
Class LongGenerator

java.lang.Object
  extended by org.apache.commons.id.AbstractLongIdentifierGenerator
      extended by org.apache.commons.id.serial.LongGenerator
All Implemented Interfaces:
java.io.Serializable, IdentifierGenerator, LongIdentifierGenerator

public class LongGenerator
extends AbstractLongIdentifierGenerator
implements java.io.Serializable

LongGenerator is an Identifier Generator that generates an incrementing number as a Long object.

If the wrap argument passed to the constructor is set to true, the sequence will wrap, returning negative values when Long.MAX_VALUE reached; otherwise an IllegalStateException will be thrown.

Version:
$Id: LongGenerator.java 480488 2006-11-29 08:57:26Z bayard $
Author:
Commons-Id team
See Also:
Serialized Form

Constructor Summary
LongGenerator(boolean wrap, long initialValue)
          Constructor.
 
Method Summary
 boolean isWrap()
          Getter for property wrap.
 java.lang.Long nextLongIdentifier()
          Gets the next identifier in the sequence.
 void setWrap(boolean wrap)
          Sets the wrap property.
 
Methods inherited from class org.apache.commons.id.AbstractLongIdentifierGenerator
maxValue, minValue, nextIdentifier
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LongGenerator

public LongGenerator(boolean wrap,
                     long initialValue)
Constructor.

Parameters:
wrap - should the factory wrap when it reaches the maximum long value (or throw an exception)
initialValue - the initial long value to start at
Method Detail

isWrap

public boolean isWrap()
Getter for property wrap.

Returns:
true if this generator is set up to wrap.

setWrap

public void setWrap(boolean wrap)
Sets the wrap property.

Parameters:
wrap - value for the wrap property

nextLongIdentifier

public java.lang.Long nextLongIdentifier()
Description copied from interface: LongIdentifierGenerator
Gets the next identifier in the sequence.

Specified by:
nextLongIdentifier in interface LongIdentifierGenerator
Specified by:
nextLongIdentifier in class AbstractLongIdentifierGenerator
Returns:
the next Long identifier in sequence


Copyright © 2003-2008 The Apache Software Foundation. All Rights Reserved.