public static String getGenerics(final String type) { if (isGeneric(type)) { return type.replaceFirst("^[^<]*(<.*?>)$", "$1"); } return ""; }
public static String getGenerics(final String type) { if (isGeneric(type)) { return new StringBuilder("<>").insert(1, getGenericsTypeParameter(type)).toString(); } return ""; }
public static String getGenericsTypeParameter(final String type) { if (isGeneric(type)) { return stripArray(type).replaceFirst("^[^<]*<(.*?)>$", "$1"); } return ""; }
public static String getGenericsTypeParameter(final String type) { if (isGeneric(type)) { return stripArray(type).replaceFirst("^[^<]*<(.*?)>$", "$1"); } return ""; }
public static String getGenerics(final String type) { if (isGeneric(type)) { return new StringBuilder("<>").insert(1, getGenericsTypeParameter(type)).toString(); } return ""; }
private static boolean validateNameWithGenerics(String name) { return isGeneric(name) || validateName(name) || WILDCARD_AWARE_TYPE_PATTERN.matcher(name).matches(); }
private static boolean validateNameWithGenerics(String name) { return isGeneric(name) || validateName(name) || WILDCARD_AWARE_TYPE_PATTERN.matcher(name).matches(); }
public static String stripGenerics(String type) { if (isClassArray(type)) { type = fixClassArray(type); } if (isGeneric(type)) { return type.substring(0, type.indexOf('<')) + type.substring(type.lastIndexOf('>') + 1).trim(); } else { return type.trim(); } }
public static String stripGenerics(String type) { if (isClassArray(type)) { type = fixClassArray(type); } if (isGeneric(type)) { return type.substring(0, type.indexOf('<')) + type.substring(type.lastIndexOf('>') + 1).trim(); } else { return type.trim(); } }
/** * Returns the dimension of the array. * * It simply counts the "[" from the string. * * @param name an array type, e.g.: byte[] or [Ljava.lang.Boolean; * @return the array dimension. 0 if the type is not a valid array */ public static int getArrayDimension(String name) { int count = 0; if (name != null) { if (isGeneric(name)) { name = stripGenerics(name); } for (char c : name.toCharArray()) { if (c == '[') { count++; } } } return count; }
@Override public boolean hasImport(final String type) { String resultType = type; if (Types.isArray(type)) { resultType = Types.stripArray(type); } if (Types.isGeneric(type)) { resultType = Types.stripGenerics(type); } return getImport(resultType) != null; }
@Override public boolean hasImport(final String type) { String resultType = type; if (Types.isArray(type)) { resultType = Types.stripArray(type); } if (Types.isGeneric(type)) { resultType = Types.stripGenerics(type); } return getImport(resultType) != null; }
@Override public boolean hasImport(final String type) { String resultType = type; if (Types.isArray(type)) { resultType = Types.stripArray(type); } if (Types.isGeneric(type)) { resultType = Types.stripGenerics(type); } return getImport(resultType) != null; }
@Override public boolean hasImport(final String type) { String resultType = type; if (Types.isArray(type)) { resultType = Types.stripArray(type); } if (Types.isGeneric(type)) { resultType = Types.stripGenerics(type); } return getImport(resultType) != null; }
@Override public boolean hasImport(final String type) { String resultType = type; if (Types.isArray(type)) { resultType = Types.stripArray(type); } if (Types.isGeneric(type)) { resultType = Types.stripGenerics(type); } return getImport(resultType) != null; }
@Override public boolean requiresImport(final String type) { String resultType = type; if (Types.isArray(resultType)) { resultType = Types.stripArray(type); } if (Types.isGeneric(resultType)) { resultType = Types.stripGenerics(resultType); } return !(!validImport(resultType) || hasImport(resultType) || Types.isJavaLang(resultType)); }
@Override public boolean requiresImport(final String type) { String resultType = type; if (Types.isArray(resultType)) { resultType = Types.stripArray(type); } if (Types.isGeneric(resultType)) { resultType = Types.stripGenerics(resultType); } if (!validImport(resultType) || hasImport(resultType) || Types.isJavaLang(resultType)) { return false; } return true; }
@Override public boolean requiresImport(final String type) { String resultType = type; if (Types.isArray(resultType)) { resultType = Types.stripArray(type); } if (Types.isGeneric(resultType)) { resultType = Types.stripGenerics(resultType); } if (!validImport(resultType) || hasImport(resultType) || Types.isJavaLang(resultType) || Strings.areEqual(getPackage(), Types.getPackage(resultType))) { return false; } return true; }
@Override public boolean requiresImport(final String type) { boolean requiresImport = false; String resultType = type; if (Types.isArray(resultType)) { resultType = Types.stripArray(resultType); } if (Types.isGeneric(resultType)) { for (String genericPart : Types.splitGenerics(resultType)) { requiresImport |= requiresImport(genericPart); } resultType = Types.stripGenerics(resultType); } requiresImport |= !(!validImport(resultType) || hasImport(resultType) || Types.isJavaLang(resultType) || Strings.areEqual(getPackage(), Types.getPackage(resultType))); return requiresImport; }
@Override public boolean requiresImport(final String type) { boolean requiresImport = false; String resultType = type; if (Types.isArray(resultType)) { resultType = Types.stripArray(resultType); } if (Types.isGeneric(resultType)) { for (String genericPart : Types.splitGenerics(resultType)) { requiresImport |= requiresImport(genericPart); } resultType = Types.stripGenerics(resultType); } requiresImport |= !(!validImport(resultType) || hasImport(resultType) || Types.isJavaLang(resultType) || Strings.areEqual(getPackage(), Types.getPackage(resultType))); return requiresImport; }