Skip to content

Instantly share code, notes, and snippets.

@Konicai
Created July 11, 2024 00:42
Show Gist options
  • Select an option

  • Save Konicai/3b64857a8e6260ed86b06194a58cfbf9 to your computer and use it in GitHub Desktop.

Select an option

Save Konicai/3b64857a8e6260ed86b06194a58cfbf9 to your computer and use it in GitHub Desktop.
private static AnnotatedType elementType(final AnnotatedType containerType) {
if (!(containerType instanceof AnnotatedParameterizedType)) {
throw new IllegalArgumentException("raw types unsupported");
}
return ((AnnotatedParameterizedType) containerType).getAnnotatedActualTypeArguments()[0];
}
private static Type listType(AnnotatedType elementType) {
return TypeFactory.parameterizedClass(List.class, elementType.getType());
}
private static Type mapType(AnnotatedType mapEntryType) {
if (!(mapEntryType instanceof AnnotatedParameterizedType)) {
throw new IllegalArgumentException("raw types unsupported");
}
AnnotatedType[] parameters = ((AnnotatedParameterizedType) mapEntryType).getAnnotatedActualTypeArguments();
return TypeFactory.parameterizedClass(Map.class, parameters[0].getType(), parameters[1].getType());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment