Java Code Examples for java.lang.reflect.AnnotatedType#getType()

The following examples show how to use java.lang.reflect.AnnotatedType#getType() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Handler.java    From greenbeans with Apache License 2.0 6 votes vote down vote up
private void compileParameters(AnnotatedType[] annotatedParameterTypes, Annotation[][] annotations) {
	ImmutableList.Builder<String> parameterOrderBuilder = ImmutableList.builder();
	ImmutableMap.Builder<String, Type> nameToTypeBuilder = ImmutableMap.builder();

	for (int x = 0; x < annotatedParameterTypes.length; ++x) {
		AnnotatedType annotatedType = annotatedParameterTypes[x];
		PathParam pathParam = getPathParam(annotations[x]);
		String name;
		Type type;
		if (pathParam != null) {
			name = pathParam.value();
			type = annotatedType.getType();
		} else {
			name = NAME_ENTITY;
			type = annotatedType.getType();
		}
		parameterOrderBuilder.add(name);
		nameToTypeBuilder.put(name, type);
	}
	parameterOrder = parameterOrderBuilder.build();
	parameterNameToType = nameToTypeBuilder.build();
}
 
Example 2
Source File: TypeParser.java    From typescript-generator with MIT License 6 votes vote down vote up
private Type getBareType(AnnotatedType annotatedType) {
    final Type type = annotatedType.getType();
    if (isArrayOfPrimitiveType(type)) {
        return type;
    }
    if (annotatedType instanceof AnnotatedParameterizedType) {
        final AnnotatedParameterizedType annotatedParameterizedType = (AnnotatedParameterizedType) annotatedType;
        final ParameterizedType parameterizedType = (ParameterizedType) type;
        return new JParameterizedType(
                parameterizedType.getRawType(),
                getTypes(annotatedParameterizedType.getAnnotatedActualTypeArguments()),
                parameterizedType.getOwnerType());
    }
    if (annotatedType instanceof AnnotatedArrayType) {
        final AnnotatedArrayType annotatedArrayType = (AnnotatedArrayType) annotatedType;
        return new JGenericArrayType(getType(annotatedArrayType.getAnnotatedGenericComponentType()));
    }
    return type;
}
 
Example 3
Source File: StubAmpBase.java    From baratine with GNU General Public License v2.0 5 votes vote down vote up
@Override
public String name()
{
  AnnotatedType annType = api();
  Type type = annType.getType();
  
  if (type instanceof Class) {
    Class<?> cl = (Class<?>) type;
    
    return "anon:" + cl.getSimpleName();
  }
  else {
    return "anon:" + type;
  }
}
 
Example 4
Source File: GsonValueMapper.java    From graphql-spqr with Apache License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public <T> T fromInput(Object graphQLInput, Type sourceType, AnnotatedType outputType) throws InputParsingException {
    if (graphQLInput.getClass() == outputType.getType()) {
        return (T) graphQLInput;
    }
    try {
        JsonElement jsonElement = NO_CONVERTERS.toJsonTree(graphQLInput, sourceType);
        return gson.fromJson(jsonElement, outputType.getType());
    } catch (JsonSyntaxException e) {
        throw new InputParsingException(graphQLInput, outputType.getType(), e);
    }
}
 
Example 5
Source File: GsonValueMapper.java    From graphql-spqr with Apache License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public <T> T fromString(String json, AnnotatedType type) {
    if (json == null || String.class.equals(type.getType())) {
        return (T) json;
    }
    try {
        return gson.fromJson(json, type.getType());
    } catch (JsonSyntaxException e) {
        throw new InputParsingException(json, type.getType(), e);
    }
}
 
Example 6
Source File: JacksonValueMapper.java    From graphql-spqr with Apache License 2.0 5 votes vote down vote up
@Override
public <T> T fromInput(Object graphQLInput, Type sourceType, AnnotatedType outputType) {
    try {
        return objectMapper.convertValue(graphQLInput, objectMapper.getTypeFactory().constructType(outputType.getType()));
    } catch (IllegalArgumentException e) {
        throw new InputParsingException(graphQLInput, outputType.getType(), e);
    }
}
 
Example 7
Source File: JacksonValueMapper.java    From graphql-spqr with Apache License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public <T> T fromString(String json, AnnotatedType type) {
    if (json == null || String.class.equals(type.getType())) {
        return (T) json;
    }
    try {
        return objectMapper.readValue(json, objectMapper.getTypeFactory().constructType(type.getType()));
    } catch (IOException e) {
        throw new InputParsingException(json, type.getType(), e);
    }
}
 
Example 8
Source File: VoidToBooleanTypeAdapter.java    From graphql-spqr with Apache License 2.0 4 votes vote down vote up
private boolean isVoid(AnnotatedType type) {
    return type.getType() == Void.TYPE || type.getType() == Void.class;
}
 
Example 9
Source File: ValidateProxy.java    From baratine with GNU General Public License v2.0 3 votes vote down vote up
private String stubClassName(StubAmp stub)
{
  AnnotatedType api = stub.api();
  
  Type type = api.getType();

  TypeRef typeRef = TypeRef.of(type);
  
  return typeRef.rawClass().getSimpleName();
}