public abstract class AbstractDataFieldMaxValueIncrementer extends Object implements DataFieldMaxValueIncrementer, InitializingBean
DataFieldMaxValueIncrementer
that delegates
to a single getNextKey()
template method that returns a long
.
Uses longs for String values, padding with zeroes if required.Modifier and Type | Field and Description |
---|---|
protected int |
paddingLength
The length to which a string result should be pre-pended with zeroes
|
Constructor and Description |
---|
AbstractDataFieldMaxValueIncrementer()
Default constructor for bean property style usage.
|
AbstractDataFieldMaxValueIncrementer(DataSource dataSource,
String incrementerName)
Convenience constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet()
Invoked by the containing
BeanFactory after it has set all bean properties
and satisfied BeanFactoryAware , ApplicationContextAware etc. |
DataSource |
getDataSource()
Return the data source to retrieve the value from.
|
String |
getIncrementerName()
Return the name of the sequence/table.
|
protected abstract long |
getNextKey()
Determine the next key to use, as a long.
|
int |
getPaddingLength()
Return the padding length for String values.
|
int |
nextIntValue()
Increment the data store field's max value as int.
|
long |
nextLongValue()
Increment the data store field's max value as long.
|
String |
nextStringValue()
Increment the data store field's max value as String.
|
void |
setDataSource(DataSource dataSource)
Set the data source to retrieve the value from.
|
void |
setIncrementerName(String incrementerName)
Set the name of the sequence/table.
|
void |
setPaddingLength(int paddingLength)
Set the padding length, i.e.
|
protected int paddingLength
public AbstractDataFieldMaxValueIncrementer()
public AbstractDataFieldMaxValueIncrementer(DataSource dataSource, String incrementerName)
dataSource
- the DataSource to useincrementerName
- the name of the sequence/table to usepublic void setDataSource(DataSource dataSource)
public DataSource getDataSource()
public void setIncrementerName(String incrementerName)
public String getIncrementerName()
public void setPaddingLength(int paddingLength)
public int getPaddingLength()
public void afterPropertiesSet()
InitializingBean
BeanFactory
after it has set all bean properties
and satisfied BeanFactoryAware
, ApplicationContextAware
etc.
This method allows the bean instance to perform validation of its overall configuration and final initialization when all bean properties have been set.
afterPropertiesSet
in interface InitializingBean
public int nextIntValue() throws DataAccessException
DataFieldMaxValueIncrementer
nextIntValue
in interface DataFieldMaxValueIncrementer
DataAccessException
- in case of errorspublic long nextLongValue() throws DataAccessException
DataFieldMaxValueIncrementer
nextLongValue
in interface DataFieldMaxValueIncrementer
DataAccessException
- in case of errorspublic String nextStringValue() throws DataAccessException
DataFieldMaxValueIncrementer
nextStringValue
in interface DataFieldMaxValueIncrementer
DataAccessException
- in case of errorsprotected abstract long getNextKey()