|
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.strategy.StringablePolicy.NameIdiom
public static final class StringablePolicy.NameIdiom
An idiom that allows the retrieval of a given StringablePolicy
defined as an enumeration constant based on an exact name of
another, possibly unrelated, policy.
The name idiom can be used in case a given stringable type contains other stringable types that should be formatted using equivalent policies (by name) in order to supply an overall textual representation.
Constructor Summary | |
---|---|
private |
StringablePolicy.NameIdiom()
Private off-limit constructor. |
Method Summary | ||
---|---|---|
static
|
getSimilarByName(Class<S> type,
T policy)
Returns the policy of type S having the exact name
as the toString() value of the policy supplied as
policy , or null if no such constant can be found. |
|
static
|
getSimilarByName(Class<S> type,
T policy,
S defaultPolicy)
Returns the policy of type S having the exact name
as the toString() value of the policy supplied as
policy , or defaultPolicy if no such constant
can be found. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
private StringablePolicy.NameIdiom()
Method Detail |
---|
public static final <S extends Enum<S> & StringablePolicy<?>,T extends StringablePolicy<?>> S getSimilarByName(Class<S> type, T policy)
S
having the exact name
as the toString()
value of the policy supplied as
policy
, or null if no such constant can be found.
For enumeration constants, the toString()
method
always returns its name.
S
- The type of the policy to return.T
- The type of the policy that supplies the name to find.type
- The enumeration type where the desired policy is to
be looked up; can be null, in which case null is returned.policy
- The policy to supply the name to look up based on its
toString
representation; can be null, in which
case null is returned.
S
having the same name as policy.toString()
, or null in
case no such constant can be found.getSimilarByName(Class, StringablePolicy, Enum)
public static final <S extends Enum<S> & StringablePolicy<?>,T extends StringablePolicy<?>> S getSimilarByName(Class<S> type, T policy, S defaultPolicy)
S
having the exact name
as the toString()
value of the policy supplied as
policy
, or defaultPolicy
if no such constant
can be found.
For enumeration constants, the toString()
method
always returns its name.
S
- The type of the policy to return.T
- The type of the policy that supplies the name to find.type
- The enumeration type where the desired policy is to
be looked up; can be null, in which case defaultPolicy
is returned.policy
- The policy to supply the name to look up based on its
toString
representation; can be null, in which
case defaultPolicy
is returned.defaultPolicy
- The default policy; can be null.
S
having the same name as policy.toString()
, or
defaultPolicy
in case no such constant can be found.getSimilarByName(Class, StringablePolicy)
|
Gunni Rode / rode.dk | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |