@Override
public TypeArgument adapt(TypeArgumentContext context) {
TypeContext typeContext = getChild(context, TypeContext.class);
if (typeContext == null) {
WildcardTypeArgument wildcardTypeArgument = createNode(context, WildcardTypeArgument.class);
return wildcardTypeArgument;
} else {
Type type = getAdapter(TypeAdapter.class).adapt(typeContext);
boolean hasExtends = hasTerminalNode(context, JavaParser.EXTENDS);
boolean hasSuper = hasTerminalNode(context, JavaParser.SUPER);
if (hasExtends || hasSuper) {
WildcardTypeArgument wildcardTypeArgument = createNode(context, WildcardTypeArgument.class);
if (hasExtends) {
wildcardTypeArgument.setExtendsType(type);
} else {
wildcardTypeArgument.setSuperType(type);
}
return wildcardTypeArgument;
} else {
return type;
}