Delegate to common ClassUtils.getQualifiedName

Issue: SPR-15237
master
Juergen Hoeller 8 years ago
parent ed85337901
commit 81aca78579
  1. 19
      spring-expression/src/main/java/org/springframework/expression/spel/ast/FormatHelper.java

@ -19,6 +19,7 @@ package org.springframework.expression.spel.ast;
import java.util.List; import java.util.List;
import org.springframework.core.convert.TypeDescriptor; import org.springframework.core.convert.TypeDescriptor;
import org.springframework.util.ClassUtils;
/** /**
* Utility methods (formatters, etc) used during parsing and evaluation. * Utility methods (formatters, etc) used during parsing and evaluation.
@ -28,10 +29,10 @@ import org.springframework.core.convert.TypeDescriptor;
public class FormatHelper { 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 name the name of the method
* @param argumentTypes the types of the arguments to 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) { public static String formatMethodForMessage(String name, List<TypeDescriptor> argumentTypes) {
StringBuilder sb = new StringBuilder(name); StringBuilder sb = new StringBuilder(name);
@ -53,16 +54,14 @@ public class FormatHelper {
} }
/** /**
* Produce a nice string for a given class object. * Determine a readable name for a given Class object.
* For example, a string array will have the formatted name "java.lang.String[]". * <p>A String array will have the formatted name "java.lang.String[]".
* @param clazz The class whose name is to be formatted * @param clazz the Class whose name is to be formatted
* @return a formatted string suitable for message inclusion * @return a formatted String suitable for message inclusion
* @see ClassUtils#getQualifiedName(Class)
*/ */
public static String formatClassNameForMessage(Class<?> clazz) { public static String formatClassNameForMessage(Class<?> clazz) {
if (clazz == null) { return (clazz != null ? ClassUtils.getQualifiedName(clazz) : "null");
return "null";
}
return clazz.getTypeName();
} }
} }

Loading…
Cancel
Save