private abstract static class WidgetId.IDGenerator
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private int |
initialValue
The value from which IDs can be allocated for created widgets.
|
protected int |
nextId
The initial value for next widget ID.
|
private boolean |
wrapped
Flag indicating the integer wrapping happen while incrementing by 1.
|
Constructor and Description |
---|
IDGenerator(int initialValue)
Create a new ID generator.
|
Modifier and Type | Method and Description |
---|---|
int |
allocateID()
Retrieve the unique per session integer id number for next new widget to create.
|
protected abstract int |
nextID()
Get the next ID, in sequential order.
|
protected abstract boolean |
usedId(int id)
Check if the given ID is already used.
|
protected abstract boolean |
wrapped(int id)
Check if the ID has wrapped.
|
protected int nextId
private final int initialValue
private boolean wrapped
public IDGenerator(int initialValue)
initialValue
- The value from which IDs can be allocated for created widgets.public int allocateID()
java.lang.RuntimeException
- If all possible IDs are in use. This is very unlikely but could happen!protected abstract int nextID()
protected abstract boolean usedId(int id)
id
- The ID to check.true
if the ID is already used by some other widget.protected abstract boolean wrapped(int id)
id
- The ID to check.true
if the ID has wrapped.