Skip to content

Commit

Permalink
Delegate to common ClassUtils.getQualifiedName
Browse files Browse the repository at this point in the history
Issue: SPR-15237
  • Loading branch information
jhoeller committed Feb 10, 2017
1 parent ed85337 commit 81aca78
Showing 1 changed file with 9 additions and 10 deletions.
Expand Up @@ -19,6 +19,7 @@
import java.util.List;

import org.springframework.core.convert.TypeDescriptor;
import org.springframework.util.ClassUtils;

/**
* Utility methods (formatters, etc) used during parsing and evaluation.
Expand All @@ -28,10 +29,10 @@
public class FormatHelper {

/**
* Produce a nice string for a given method name with specified arguments.
* Produce a readable representation for a given method name with specified arguments.
* @param name the name of the method
* @param argumentTypes the types of the arguments to the method
* @return nicely formatted string, eg. foo(String,int)
* @return a nicely formatted representation, e.g. {@code foo(String,int)}
*/
public static String formatMethodForMessage(String name, List<TypeDescriptor> argumentTypes) {
StringBuilder sb = new StringBuilder(name);
Expand All @@ -53,16 +54,14 @@ public static String formatMethodForMessage(String name, List<TypeDescriptor> ar
}

/**
* Produce a nice string for a given class object.
* For example, a string array will have the formatted name "java.lang.String[]".
* @param clazz The class whose name is to be formatted
* @return a formatted string suitable for message inclusion
* Determine a readable name for a given Class object.
* <p>A String array will have the formatted name "java.lang.String[]".
* @param clazz the Class whose name is to be formatted
* @return a formatted String suitable for message inclusion
* @see ClassUtils#getQualifiedName(Class)
*/
public static String formatClassNameForMessage(Class<?> clazz) {
if (clazz == null) {
return "null";
}
return clazz.getTypeName();
return (clazz != null ? ClassUtils.getQualifiedName(clazz) : "null");
}

}

0 comments on commit 81aca78

Please sign in to comment.