public class PersistentKeyGenerator extends java.lang.Object implements KeyGenerator
NumberSeries functionality of the platform for getting unique
numbers in a series persisted via database. It provides several setter methods for configuration of the used number
series like the key of the series at database. It is lazily initialized on first call.| Modifier and Type | Class and Description |
|---|---|
static class |
PersistentKeyGenerator.Type |
| Modifier and Type | Field and Description |
|---|---|
protected int |
digits
Amount of digits used for one key.
|
protected java.lang.String |
key
Key of series.
|
protected boolean |
numeric
Is the series numeric or alpha-numeric?
|
protected java.lang.String |
start
Start value for series (used in case the series is not created yet and at a reset).
|
protected java.lang.String |
template
Template to be applied on generated value
|
| Constructor and Description |
|---|
PersistentKeyGenerator() |
| Modifier and Type | Method and Description |
|---|---|
protected NumberSeries |
createSeriesAfterLookupError(NumberSeriesManager nsm) |
java.lang.Object |
generate()
Generates a new unique key.
|
java.lang.Object |
generateFor(java.lang.Object object)
Generates a new unique key in relation to given object.
|
void |
init()
Deprecated.
since 5.0 favour lazy initialization while fetching the sequence for the first time
|
void |
initializeKeyGenerator() |
protected NumberSeries |
lookup(NumberSeriesManager nsm) |
void |
reset()
Resets the key generation so that an already generated key can be generated once again.
|
void |
setDigits(int digits)
Sets the amount of digits within one generated key.
|
void |
setKey(java.lang.String key)
Sets the key of the number series to use.
|
void |
setNumeric(boolean numeric)
Deprecated.
since ages - use
setType(de.hybris.platform.servicelayer.keygenerator.impl.PersistentKeyGenerator.Type)
instead. |
void |
setStart(java.lang.String start)
|
void |
setTemplate(java.lang.String template)
Sets the template of the number series to use.
|
void |
setType(PersistentKeyGenerator.Type type)
Sets type of the key generator.
|
protected java.lang.String key
protected int digits
protected java.lang.String start
protected java.lang.String template
protected boolean numeric
@PostConstruct public void initializeKeyGenerator()
public java.lang.Object generate()
KeyGeneratorKeyGenerator.reset() method the generator is reseted so that a key
can be returned which already was returned before calling KeyGenerator.reset().generate in interface KeyGeneratorpublic java.lang.Object generateFor(java.lang.Object object)
KeyGeneratorKeyGenerator.generate()
method and furthermore it is guaranteed that the key will only be produced for this object (think of a PK which
contains the type information, a media PK will not be generated for a product, nevertheless it is unique overall).generateFor in interface KeyGeneratorobject - object for which a key will be generatedpublic void reset()
KeyGeneratorreset in interface KeyGenerator@Deprecated public void init()
protected NumberSeries lookup(NumberSeriesManager nsm) throws JaloInvalidParameterException
JaloInvalidParameterExceptionprotected NumberSeries createSeriesAfterLookupError(NumberSeriesManager nsm)
public void setTemplate(java.lang.String template)
template - number series templatepublic void setKey(java.lang.String key)
key - number series keypublic void setDigits(int digits)
digits - amount of digitspublic void setStart(java.lang.String start)
init() or at a
reset().start - start value@Deprecated public void setNumeric(boolean numeric)
setType(de.hybris.platform.servicelayer.keygenerator.impl.PersistentKeyGenerator.Type)
instead.init()
or at a reset().numeric - is the series numeric?public void setType(PersistentKeyGenerator.Type type)
NumberSeriestype - type of key generatorCopyright © 2018 SAP SE. All Rights Reserved.