@Test void prettyPrintTypeClass() { final String string = spoonCodeInstrument.prettyPrintType(CtClass.class); assertThat(string).isEqualTo("CtClass"); }
String prettyPrintType(final Type type) { if(type instanceof Class) { return ((Class<?>) type).getSimpleName(); } if(type instanceof ParameterizedType) { final ParameterizedType paramType = (ParameterizedType) type; return getUnqualifiedClassName(paramType.getRawType().getTypeName()) + Arrays .stream(paramType.getActualTypeArguments()) .map(arg -> prettyPrintType(arg)) .collect(Collectors.joining(", ", "<", ">")); } return type.getTypeName(); }
SpoonCodeInstrument extends JfxInstrument implements Initializable { String prettyPrintType(final Type type) { if(type instanceof Class) { return ((Class<?>) type).getSimpleName(); } if(type instanceof ParameterizedType) { final ParameterizedType paramType = (ParameterizedType) type; return getUnqualifiedClassName(paramType.getRawType().getTypeName()) + Arrays .stream(paramType.getActualTypeArguments()) .map(arg -> prettyPrintType(arg)) .collect(Collectors.joining(", ", "<", ">")); } return type.getTypeName(); } }
SpoonCodeInstrument extends JfxInstrument implements Initializable { String prettyPrintType(final Type type) { if(type instanceof Class) { return ((Class<?>) type).getSimpleName(); } if(type instanceof ParameterizedType) { final ParameterizedType paramType = (ParameterizedType) type; return getUnqualifiedClassName(paramType.getRawType().getTypeName()) + Arrays .stream(paramType.getActualTypeArguments()) .map(arg -> prettyPrintType(arg)) .collect(Collectors.joining(", ", "<", ">")); } return type.getTypeName(); }  }
SpoonCodeInstrument extends JfxInstrument implements Initializable { String prettyPrintType(final Type type) { if(type instanceof Class) { return ((Class<?>) type).getSimpleName(); } if(type instanceof ParameterizedType) { final ParameterizedType paramType = (ParameterizedType) type; return getUnqualifiedClassName(paramType.getRawType().getTypeName()) + Arrays .stream(paramType.getActualTypeArguments()) .map(arg -> prettyPrintType(arg)) .collect(Collectors.joining(", ", "<", ">")); } return type.getTypeName(); }  @Override void initialize(final URL url, final ResourceBundle res); }
SpoonCodeInstrument extends JfxInstrument implements Initializable { String prettyPrintType(final Type type) { if(type instanceof Class) { return ((Class<?>) type).getSimpleName(); } if(type instanceof ParameterizedType) { final ParameterizedType paramType = (ParameterizedType) type; return getUnqualifiedClassName(paramType.getRawType().getTypeName()) + Arrays .stream(paramType.getActualTypeArguments()) .map(arg -> prettyPrintType(arg)) .collect(Collectors.joining(", ", "<", ">")); } return type.getTypeName(); }  @Override void initialize(final URL url, final ResourceBundle res);  }