|
Evaluating Software Design Patterns — the "Gang of Four" patterns implemented in Java 6 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object dk.rode.thesis.meta.model.AbstractSequence<E> dk.rode.thesis.meta.model.ArraySequence<String> dk.rode.thesis.singleton.NorwegianAlphabetSequence
@Participant(value="Singleton") @Singleton public final class NorwegianAlphabetSequence
A singleton alphabet sequence for letters in the Norwegian alphabet:
a
though z
as well as æ
, ø
, and
å
, all lower-cased.
Only a single instance of this class is created, and is available
via the getInstance()
method.
This class cannot be sub-classed.
Implementation notes:
A single instance of NorwegianAlphabetSequence
is always created at
class loading time in a thread-safe manner by using standard static
initialisation. For example, accessing the static field SIZE
will cause the singleton instance to be created. Hence, each call to
getInstance()
does not have to be synchronised or check to see if
the single instance has been created.
A CallerClass
is used to ensure that only this class itself can
create the singleton instance.
Any singleton instance in Java is only a singleton per class loader if created based on and utilising intrinsic class features.
Note that the standard ArraySequence
hashCode
and
equals(Object)
still works for singleton sub-classes of it.
DanishAlphabetSequence
,
SimpsonsFamilySequence
,
SimpsonsAndBouvierFamilySequence
,
SmileySequence
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface dk.rode.thesis.meta.model.Sequence |
---|
Sequence.State |
Field Summary | |
---|---|
private static String[] |
alphabet
The letters in the Norwegian alphabet. |
private static NorwegianAlphabetSequence |
instance
Single instance of the sequence, initialised thread-safe at class loading time. |
static int |
SIZE
The size of the Norwegian alphabet. |
Fields inherited from class dk.rode.thesis.meta.model.ArraySequence |
---|
elements, index |
Fields inherited from class dk.rode.thesis.meta.model.AbstractSequence |
---|
state |
Constructor Summary | |
---|---|
private |
NorwegianAlphabetSequence()
Private no-arg constructor. |
Method Summary | |
---|---|
NorwegianAlphabetSequence |
copy()
Returns this instance. |
static NorwegianAlphabetSequence |
getInstance()
Returns the NorwegianAlphabetSequence singleton
instance to use. |
Methods inherited from class dk.rode.thesis.meta.model.ArraySequence |
---|
bounded, consistent, current, equals, hashCode, next, reset, size, unique |
Methods inherited from class dk.rode.thesis.meta.model.AbstractSequence |
---|
getStringablePolicy, state, toString, toString |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface dk.rode.thesis.meta.model.Sequence |
---|
state |
Methods inherited from interface dk.rode.thesis.strategy.Stringable |
---|
getStringablePolicy, toString |
Field Detail |
---|
private static final String[] alphabet
private static final NorwegianAlphabetSequence instance
Never null.
public static final int SIZE
Implementation notes:
Accessing this static field before getInstance()
will cause the singleton instance to be created!
DanishAlphabetSequence.SIZE
,
SimpsonsFamilySequence.SIZE
,
SimpsonsAndBouvierFamilySequence.SIZE
,
SmileySequence.SIZE
Constructor Detail |
---|
private NorwegianAlphabetSequence()
SingletonError
- If another class tries to invoke
this constructor (via reflection).Method Detail |
---|
public final NorwegianAlphabetSequence copy()
public static final NorwegianAlphabetSequence getInstance()
NorwegianAlphabetSequence
singleton
instance to use.
Singleton
|
Gunni Rode / rode.dk | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |