|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.joda.convert.RenameHandler
public final class RenameHandler
A general purpose utility for registering renames.
This handles type and enum constant renames. For example, use as follows:
RenameHandler.INSTANCE.renamedType("org.joda.OldName", NewName.class);
RenameHandler.INSTANCE.renamedEnum("CORRECT", Status.VALID);
RenameHandler.INSTANCE.renamedEnum("INCORRECT", Status.INVALID);
The recommended usage is to edit the static singleton before using other classes.
Editing a static is acceptable because renames are driven by bytecode which is static.
For additional security, an application should lock the rename handler instance
once any types and enums have been registered using lock().
This class is thread-safe with concurrent caches.
| Field Summary | |
|---|---|
static RenameHandler |
INSTANCE
A mutable global instance. |
| Method Summary | ||
|---|---|---|
static RenameHandler |
create()
Creates an instance. |
|
Map<String,Enum<?>> |
getEnumRenames(Class<?> type)
Gets the map of renamed for an enum type. |
|
Set<Class<?>> |
getEnumTypesWithRenames()
Gets the set of enum types that have renames. |
|
Map<String,Class<?>> |
getTypeRenames()
Gets the map of renamed types. |
|
void |
lock()
Locks this instance of the rename handler. |
|
|
lookupEnum(Class<T> type,
String name)
Lookup an enum from a name, handling renames. |
|
Class<?> |
lookupType(String name)
Lookup a type from a name, handling renames. |
|
void |
renamedEnum(String oldName,
Enum<?> currentValue)
Register the fact that an enum constant was renamed. |
|
void |
renamedType(String oldName,
Class<?> currentValue)
Register the fact that a type was renamed. |
|
String |
toString()
|
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final RenameHandler INSTANCE
| Method Detail |
|---|
public static RenameHandler create()
This is not normally used as the preferred option is to edit the singleton.
public void renamedType(String oldName,
Class<?> currentValue)
This handles the use case where a class is renamed.
oldName - the old name of the type including the package name, not nullcurrentValue - the current type, not nullpublic Map<String,Class<?>> getTypeRenames()
An empty map is returned if there are no renames.
public Class<?> lookupType(String name)
throws ClassNotFoundException
name - the name of the type to lookup, not null
ClassNotFoundException - if the name is not a valid type
public void renamedEnum(String oldName,
Enum<?> currentValue)
This handles the use case where an enum constant is renamed, but the enum class remains the same.
oldName - the old name of the enum constant, not nullcurrentValue - the current enum constant, not nullpublic Set<Class<?>> getEnumTypesWithRenames()
An empty set is returned if there are no renames.
public Map<String,Enum<?>> getEnumRenames(Class<?> type)
An empty map is returned if there are no renames.
type - the enum type, not null
public <T extends Enum<T>> T lookupEnum(Class<T> type,
String name)
T - the type of the desired enumtype - the enum type, not nullname - the name of the enum to lookup, not null
IllegalArgumentException - if the name is not a valid enum constantpublic void lock()
For additional security, an application should lock the rename handler once any types and enums have been registered.
public String toString()
toString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||