String declString(Type type) { final String modifiers = Modifier.toString(modifier); return modifiers + (modifiers.isEmpty() ? "" : " ") + Types.className(type) + " " + name; }
@Override public String toString() { final StringBuilder buf = new StringBuilder(); buf.append(className(rawType)); buf.append("<"); int i = 0; for (Type typeArgument : typeArguments) { if (i++ > 0) { buf.append(", "); } buf.append(className(typeArgument)); } buf.append(">"); return buf.toString(); }
static String className(Type type) { if (type instanceof ArrayType) { return className(((ArrayType) type).getComponentType()) + "[]"; } if (!(type instanceof Class)) { return type.toString(); } Class clazz = (Class) type; if (clazz.isArray()) { return className(clazz.getComponentType()) + "[]"; } String className = clazz.getName(); if (!clazz.isPrimitive() && clazz.getPackage() != null && clazz.getPackage().getName().equals("java.lang")) { return className.substring("java.lang.".length()); } return className.replace('$', '.'); }
public ExpressionWriter append(Type type) { checkIndent(); if (!generics) { type = Types.stripGenerics(type); } buf.append(Types.className(type)); return this; }
/** * Boxes a type, if it is primitive, and returns the type name. * The type is abbreviated if it is in the "java.lang" package. * * <p>For example, * boxClassName(int) returns "Integer"; * boxClassName(List<String>) returns "List<String>"</p> * * @param type Type * * @return Class name */ static String boxClassName(Type type) { if (!(type instanceof Class)) { return type.toString(); } Primitive primitive = Primitive.of(type); if (primitive != null) { return primitive.boxClass.getSimpleName(); } else { return className(type); } }
public void accept(ExpressionWriter writer) { String modifiers = Modifier.toString(modifier); writer.append(modifiers); if (!modifiers.isEmpty()) { writer.append(' '); } writer .append(resultType) .list("(", ", ", ")", Lists.transform(parameters, parameter -> { final String modifiers1 = Modifier.toString(parameter.modifier); return modifiers1 + (modifiers1.isEmpty() ? "" : " ") + Types.className(parameter.getType()) + " " + parameter.name; })) .append(' ').append(body); writer.newlineAndIndent(); }
final Type parameterType = parameterExpression.getType(); final Type parameterBoxType = Types.box(parameterType); final String parameterBoxTypeName = Types.className(parameterBoxType); params.add(parameterExpression.declString()); bridgeParams.add(parameterExpression.declString(Object.class)); .begin(" {\n") .append("public ") .append(Types.className(resultType2)) .list(" " + methodName + "(", ", ", ") ", params) ? Types.className(bridgeResultType) : Types.boxClassName(bridgeResultType); if (!boxBridgeParams.equals(params)) {