java.lang.reflect.Method.getAnnotatedReturnType()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(8.0k)|赞(0)|评价(0)|浏览(116)

本文整理了Java中java.lang.reflect.Method.getAnnotatedReturnType()方法的一些代码示例,展示了Method.getAnnotatedReturnType()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Method.getAnnotatedReturnType()方法的具体详情如下:
包路径:java.lang.reflect.Method
类名称:Method
方法名:getAnnotatedReturnType

Method.getAnnotatedReturnType介绍

暂无

代码示例

代码示例来源:origin: google/guava

@Override
public AnnotatedType getAnnotatedReturnType() {
 return method.getAnnotatedReturnType();
}

代码示例来源:origin: thinkaurelius/titan

AnnotatedType rt = method.getAnnotatedReturnType();
System.out.println(rt.getType());
System.out.println(rt.getAnnotations().length);

代码示例来源:origin: JanusGraph/janusgraph

AnnotatedType rt = method.getAnnotatedReturnType();
System.out.println(rt.getType());
System.out.println(rt.getAnnotations().length);

代码示例来源:origin: immutables/immutables

@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();
}

代码示例来源:origin: pholser/junit-quickcheck

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);
  }
}

代码示例来源:origin: org.weakref/jmxutils

@Override
public AnnotatedType getAnnotatedReturnType() {
 return method.getAnnotatedReturnType();
}

代码示例来源:origin: org.minijax/minijax-validator

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);
}

代码示例来源:origin: Enigmatis/graphql-java-annotations

@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);
}

代码示例来源:origin: io.vertx/vertx-codegen

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);
 }
});

代码示例来源:origin: io.leangen.geantyref/geantyref

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);
}

代码示例来源:origin: org.osgi/osgi.enroute.rest.simple.provider

private void doResponses(OperationObject operationObject, Function function)
    throws Exception {
  doResponse(operationObject, function.method.getAnnotatedReturnType());
  for (AnnotatedType annotatedException : function.method
      .getAnnotatedExceptionTypes()) {
    doResponse(operationObject, annotatedException, annotatedException);
  }
}

代码示例来源:origin: Enigmatis/graphql-java-annotations

@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);
}

代码示例来源:origin: Enigmatis/graphql-java-annotations

@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);
}

代码示例来源:origin: Enigmatis/graphql-java-annotations

@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);
}

代码示例来源:origin: Enigmatis/graphql-java-annotations

@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);
}

代码示例来源:origin: Enigmatis/graphql-java-annotations

@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);
}

代码示例来源:origin: Enigmatis/graphql-java-annotations

@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);
}

代码示例来源:origin: Enigmatis/graphql-java-annotations

@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);
}

代码示例来源:origin: Enigmatis/graphql-java-annotations

@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);
}

代码示例来源:origin: Enigmatis/graphql-java-annotations

@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);
}

相关文章

微信公众号

最新文章

更多