public static String filterTypeName(Class<?> type) { if (type != null) { if (!type.isPrimitive() && !(type.isArray() && ArrayTool.getLowerComponentType(type).isPrimitive())) { // for not primitives // return String.format( "%s.%s", ClassUtils.getPackageName(type), ClassUtils.getShortClassName(type)); } else { return ClassUtils.getShortClassName(type); } } return StringUtils.EMPTY; }
/** * Gets the package name from the canonical name. * * <p>The string passed in is assumed to be a canonical name - it is not checked. * * <p>If the class is unpackaged, return an empty string. * * @param canonicalName the canonical name to get the package name for, may be <code>null</code> * @return the package name or an empty string * @since 2.4 */ public static String getPackageCanonicalName(String canonicalName) { return ClassUtils.getPackageName(getCanonicalName(canonicalName)); }