org.apache.ws.jaxme.js.pattern

Class TypesafeEnumerationGenerator


public class TypesafeEnumerationGenerator
extends java.lang.Object

This class is a generator for the typesafe enumeration pattern. It creates a class that contains only a few, specified instances. Other instances cannot be created.

Any instance has a name and a value. The name

Version:
$Id: TypesafeEnumerationGenerator.java 231785 2004-02-17 00:39:59 +0100 (Tue, 17 Feb 2004) jochen $
Author:
Jochen Wiedmann

Nested Class Summary

static class
TypesafeEnumerationGenerator.Item

Method Summary

JavaInnerClass
generate(JavaSource pSource, String pName, TypesafeEnumerationGenerator.Item[] pItems)
Generates a new typesafe enumeration, which is an inner class of the class pSource.
JavaSource
generate(JavaSourceFactory pFactory, JavaQName pTargetClass, TypesafeEnumerationGenerator.Item[] pItems)
Generates a new typesafe enumeration.
boolean
isAddingEquals()
Returns whether the generator should add implementations for the methods Object.equals(java.lang.Object) and Object.hashCode() or not.
void
setAddingEquals(boolean pAddingEquals)
Sets whether the generator should add implementations for the methods Object.equals(java.lang.Object) and Object.hashCode() or not.

Method Details

generate

public JavaInnerClass generate(JavaSource pSource,
                               String pName,
                               TypesafeEnumerationGenerator.Item[] pItems)
Generates a new typesafe enumeration, which is an inner class of the class pSource.
Parameters:
pSource - The class, which shall have an inner class
pName - Name of the inner class
pItems - The enumeration items; a public, static, final instance will be generated for any element in the array

generate

public JavaSource generate(JavaSourceFactory pFactory,
                           JavaQName pTargetClass,
                           TypesafeEnumerationGenerator.Item[] pItems)
Generates a new typesafe enumeration.
Parameters:
pFactory - The factory to use for generating the items.
pTargetClass - Fully qualified name of the class being generated.
pItems - The enumeration items; a public, static, final instance will be generated for any element in the array

isAddingEquals

public boolean isAddingEquals()
Returns whether the generator should add implementations for the methods Object.equals(java.lang.Object) and Object.hashCode() or not. Defaults to true.

setAddingEquals

public void setAddingEquals(boolean pAddingEquals)
Sets whether the generator should add implementations for the methods Object.equals(java.lang.Object) and Object.hashCode() or not. Defaults to true.