Evaluating Software Design Patterns
— the "Gang of Four" patterns implemented in Java 6

dk.rode.thesis.composite
Enum CompositePolicy

java.lang.Object
  extended by java.lang.Enum<CompositePolicy>
      extended by dk.rode.thesis.composite.CompositePolicy
All Implemented Interfaces:
StringablePolicy<Sequence<?>>, Serializable, Comparable<CompositePolicy>

public enum CompositePolicy
extends Enum<CompositePolicy>
implements StringablePolicy<Sequence<?>>

Additional policies for formatting SequenceDecorator objects into char sequences (not part of the core Composite implementation).

Implementation notes:
This is NOT part of the core Composite functionality, merely to provide better log descriptions!

See implementation notes for the ObjectPolicy enumeration.

Author:
Gunni Rode / rode.dk
See Also:
SequencePolicy

Nested Class Summary
 
Nested classes/interfaces inherited from interface dk.rode.thesis.strategy.StringablePolicy
StringablePolicy.NameIdiom, StringablePolicy.Type
 
Enum Constant Summary
VISIBLE
          Policy used to format string representations of composite sequences that indicates the structure.
 
Method Summary
 StringablePolicy.Type type()
          Returns the type of this policy.
static CompositePolicy valueOf(String name)
          Returns the enum constant of this type with the specified name.
static CompositePolicy[] values()
          Returns an array containing the constants of this enum type, in the order they are declared.
 
Methods inherited from class java.lang.Enum
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface dk.rode.thesis.strategy.StringablePolicy
toString
 

Enum Constant Detail

VISIBLE

public static final CompositePolicy VISIBLE
Policy used to format string representations of composite sequences that indicates the structure.

Note, however, that the check for composite sequences is done using instanceof, which will not discover adapted, decorated, or proxied sequences!

Method Detail

type

public StringablePolicy.Type type()
Description copied from interface: StringablePolicy
Returns the type of this policy.

The stringable context can use the type to decide how to use the textual representation of this policy in conjunction with additional text.

Specified by:
type in interface StringablePolicy<Sequence<?>>
Returns:
StringablePolicy.Type.APPENDABLE.

valueOf

public static CompositePolicy valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

Parameters:
name - the name of the enum constant to be returned.
Returns:
the enum constant with the specified name
Throws:
IllegalArgumentException - if this enum type has no constant with the specified name
NullPointerException - if the argument is null

values

public static CompositePolicy[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
for (CompositePolicy c : CompositePolicy.values())
    System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they are declared

Gunni Rode / rode.dk

Feel free to use and/or modify the Java 6 source code developed for this thesis AT YOUR OWN RISK, but note that the source code comes WITHOUT ANY — and I do mean WITHOUT ANY — form of warranty WHAT SO EVER!

The original thesis and source code are available at rode.dk/thesis.