Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
/target/
/target/
typeconverter.iml
.idea/
29 changes: 20 additions & 9 deletions src/main/java/com/toddfast/util/convert/TypeConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,17 @@ private static Map<Object,Conversion<?>> getTypeConversions() {
return typeConversions;
}

/**
* Return an immutable copy of the currently registered type conversion
* objects. The keys for the values in this map may be arbitrary objects, but
* the values are of type <code>Conversion</code>
*
* @return Copy of the registred type conversions
*/
public static Map<Object,Conversion<?>> getRegisteredTypeConversions() {
return Collections.unmodifiableMap(new LinkedHashMap<Object,Conversion<?>>(typeConversions));
}

/**
* Register a type conversion object under the specified key. This
* method can be used by developers to register custom type conversion
Expand All @@ -188,14 +199,6 @@ public static void registerTypeConversion(Object key,
typeConversions.put(key,conversion);
}

/**
* Unregister a type conversion object under the specified key
*
*/
public static void unregisterTypeConversion(Object key) {
typeConversions.remove(key);
}

/**
* Register a type conversion object under the specified keys. This
* method can be used by developers to register custom type conversion
Expand All @@ -214,6 +217,14 @@ public static void registerTypeConversion(Conversion<?> conversion) {
}
}

/**
* Unregister a type conversion object under the specified key
*
*/
public static void unregisterTypeConversion(Object key) {
typeConversions.remove(key);
}

/**
* Unregister a type conversion object under all keys it specifies via
* the {@link TypeConversion#getTypeKeys} method. Note, if this conversion
Expand All @@ -224,7 +235,7 @@ public static void unregisterTypeConversion(Conversion<?> conversion) {
if (conversion!=null) {
Object[] keys=conversion.getTypeKeys();
synchronized (typeConversions) {
if (keys==null) {
if (keys!=null) {
for (int i=0; i<keys.length; i++) {
unregisterTypeConversion(keys[i]);
}
Expand Down