@Override public AnnotatedType getAnnotatedReturnType() { return method.getAnnotatedReturnType(); }
AnnotatedType rt = method.getAnnotatedReturnType(); System.out.println(rt.getType()); System.out.println(rt.getAnnotations().length);
AnnotatedType rt = method.getAnnotatedReturnType(); System.out.println(rt.getType()); System.out.println(rt.getAnnotations().length);
@Test public void java8TypeAnnotation() throws Exception { Method method = ImmutableHasTypeAnnotation.class.getMethod("str"); AnnotatedType returnType = method.getAnnotatedReturnType(); check(returnType.getAnnotation(TypeA.class)).notNull(); check(returnType.getAnnotation(TypeB.class)).notNull(); }
private void maybeAddLambdaGenerator( ParameterTypeContext parameter, List<Generator<?>> matches) { Method method = singleAbstractMethodOf(parameter.getRawClass()); if (method != null) { ParameterTypeContext returnType = new ParameterTypeContext( "return value", method.getAnnotatedReturnType(), method.getName()) .annotate(method.getAnnotatedReturnType()) .allowMixedTypes(true); Generator<?> returnTypeGenerator = generatorFor(returnType); Generator<?> lambda = new LambdaGenerator<>(parameter.getRawClass(), returnTypeGenerator); matches.add(lambda); } }
@Override public AnnotatedType getAnnotatedReturnType() { return method.getAnnotatedReturnType(); }
public MinijaxGetterDescriptor(final Method getter) { super(getter.getDeclaringClass(), getter.getAnnotatedReturnType(), getter.getAnnotations()); this.getter = getter; propertyName = getter.getName().substring(3, 4).toLowerCase() + getter.getName().substring(4); }
@Override public GraphQLType build() { AnnotatedType annotatedReturnType = method.getAnnotatedReturnType(); TypeFunction typeFunction; if (method.getAnnotation(GraphQLBatched.class) != null) { typeFunction = new BatchedTypeFunction(this.typeFunction); } else { typeFunction = this.typeFunction; } return typeFunction.buildType(isInput,method.getReturnType(), annotatedReturnType, container); }
public TypeUse.TypeInternal forReturn(ProcessingEnvironment env, ExecutableElement methodElt) { Method methodRef = getMethod(env, methodElt); if (methodRef == null) { return null; } AnnotatedType annotated = methodRef.getAnnotatedReturnType(); return new ReflectType(annotated); } });
private static AnnotatedType getReturnType(Method m, AnnotatedType declaringType, VarMap.MappingMode mappingMode) { AnnotatedType returnType = m.getAnnotatedReturnType(); AnnotatedType exactDeclaringType = getExactSuperType(capture(declaringType), m.getDeclaringClass()); if (exactDeclaringType == null) { // capture(type) is not a subtype of m.getDeclaringClass() throw new IllegalArgumentException("The method " + m + " is not a member of type " + declaringType); } return mapTypeParameters(returnType, exactDeclaringType, mappingMode); }
private void doResponses(OperationObject operationObject, Function function) throws Exception { doResponse(operationObject, function.method.getAnnotatedReturnType()); for (AnnotatedType annotatedException : function.method .getAnnotatedExceptionTypes()) { doResponse(operationObject, annotatedException, annotatedException); } }
@Test public void buildType_integerMethodAnnotatedWithGraphQLID_returnsGraphQLID() throws NoSuchMethodException { // Arrange DefaultTypeFunction instance = testedDefaultTypeFunction(); Method idIntegerMethod = IDFunctionTests.class.getMethod("idIntegerMethod"); // Act+Assert assertEquals(instance.buildType(idIntegerMethod.getReturnType(), idIntegerMethod.getAnnotatedReturnType(),null), GraphQLID); }
@Test public void buildType_intMethodAnnotatedWithGraphQLID_returnsGraphQLID() throws NoSuchMethodException { // Arrange DefaultTypeFunction instance = testedDefaultTypeFunction(); Method idIntMethod = IDFunctionTests.class.getMethod("idIntMethod"); // Act+Assert assertEquals(instance.buildType(idIntMethod.getReturnType(), idIntMethod.getAnnotatedReturnType(),null), GraphQLID); }
@Test public void buildType_stringMethodAnnotatedWithGraphQLID_returnsGraphQLID() throws NoSuchMethodException, NoSuchFieldException { // Arrange DefaultTypeFunction instance = testedDefaultTypeFunction(); Method idStringMethod = IDFunctionTests.class.getMethod("idStringMethod"); // Act+Assert assertEquals(instance.buildType(idStringMethod.getReturnType(), idStringMethod.getAnnotatedReturnType(),null), GraphQLID); }
@Test public void optional() throws NoSuchMethodException { ProcessingElementsContainer container = testedProcessingElementsContainer(); graphql.schema.GraphQLType type = container.getDefaultTypeFunction().buildType(getClass().getMethod("optionalMethod").getReturnType(), getClass().getMethod("listMethod").getAnnotatedReturnType(),null); assertTrue(type instanceof GraphQLList); GraphQLType subtype = ((GraphQLList) type).getWrappedType(); assertTrue(subtype instanceof graphql.schema.GraphQLNonNull); GraphQLType wrappedType = (((graphql.schema.GraphQLNonNull) subtype).getWrappedType()); assertEquals(wrappedType, GraphQLString); }
@Test public void buildType_listType_returnsCorrectGraphQLType() throws NoSuchMethodException { ProcessingElementsContainer container = testedProcessingElementsContainer(); graphql.schema.GraphQLType type = container.getDefaultTypeFunction().buildType(getClass().getMethod("listMethod").getReturnType(), getClass().getMethod("listMethod").getAnnotatedReturnType(),null); assertIsGraphListOfListOfString(type); }
@Test public void buildType_collectionType_returnsCorrectGraphQLType() throws NoSuchMethodException { ProcessingElementsContainer container = testedProcessingElementsContainer(); graphql.schema.GraphQLType type = container.getDefaultTypeFunction().buildType(getClass().getMethod("collectionMethod").getReturnType(), getClass().getMethod("collectionMethod").getAnnotatedReturnType(),null); assertIsGraphListOfListOfString(type); }
@Test public void buildType_streamType_returnsCorrectGraphQLType() throws NoSuchMethodException { ProcessingElementsContainer container = testedProcessingElementsContainer(); graphql.schema.GraphQLType type = container.getDefaultTypeFunction().buildType(getClass().getMethod("streamMethod").getReturnType(), getClass().getMethod("listMethod").getAnnotatedReturnType(),null); assertIsGraphListOfListOfString(type); }
@Test public void buildType_iterableType_returnsCorrectGraphQLType() throws NoSuchMethodException { ProcessingElementsContainer container = testedProcessingElementsContainer(); graphql.schema.GraphQLType type = container.getDefaultTypeFunction().buildType(getClass().getMethod("iterableMethod").getReturnType(), getClass().getMethod("iterableMethod").getAnnotatedReturnType(),null); assertIsGraphListOfListOfString(type); }
@Test public void buildType_setType_returnsCorrectGraphQLType() throws NoSuchMethodException { ProcessingElementsContainer container = testedProcessingElementsContainer(); graphql.schema.GraphQLType type = container.getDefaultTypeFunction().buildType(getClass().getMethod("setMethod").getReturnType(), getClass().getMethod("setMethod").getAnnotatedReturnType(),null); assertIsGraphListOfListOfString(type); }