org.springframework.core.convert.TypeDescriptor.hasAnnotation()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(3.5k)|赞(0)|评价(0)|浏览(92)

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

TypeDescriptor.hasAnnotation介绍

[英]Determine if this type descriptor has the specified annotation.

As of Spring Framework 4.2, this method supports arbitrary levels of meta-annotations.
[中]确定此类型描述符是否具有指定的注释。
从Spring Framework 4.2开始,这种方法支持任意级别的元注释。

代码示例

代码示例来源:origin: spring-projects/spring-framework

@Override
public boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType) {
  return targetType.hasAnnotation(this.annotationType);
}

代码示例来源:origin: spring-projects/spring-framework

@Override
public boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType) {
  return sourceType.hasAnnotation(this.annotationType);
}

代码示例来源:origin: org.springframework/spring-context

@Override
public boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType) {
  return sourceType.hasAnnotation(this.annotationType);
}

代码示例来源:origin: org.springframework/spring-context

@Override
public boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType) {
  return targetType.hasAnnotation(this.annotationType);
}

代码示例来源:origin: spring-projects/spring-framework

@Test
public void propertyGenericClassList() throws Exception {
  IntegerClass genericBean = new IntegerClass();
  Property property = new Property(genericBean.getClass(), genericBean.getClass().getMethod("getListProperty"),
      genericBean.getClass().getMethod("setListProperty", List.class));
  TypeDescriptor desc = new TypeDescriptor(property);
  assertEquals(List.class, desc.getType());
  assertEquals(Integer.class, desc.getElementTypeDescriptor().getType());
  assertNotNull(desc.getAnnotation(MethodAnnotation1.class));
  assertTrue(desc.hasAnnotation(MethodAnnotation1.class));
}

代码示例来源:origin: spring-projects/spring-framework

@Test
public void parameterAnnotated() throws Exception {
  TypeDescriptor t1 = new TypeDescriptor(new MethodParameter(getClass().getMethod("testAnnotatedMethod", String.class), 0));
  assertEquals(String.class, t1.getType());
  assertEquals(1, t1.getAnnotations().length);
  assertNotNull(t1.getAnnotation(ParameterAnnotation.class));
  assertTrue(t1.hasAnnotation(ParameterAnnotation.class));
  assertEquals(123, t1.getAnnotation(ParameterAnnotation.class).value());
}

代码示例来源:origin: apache/servicemix-bundles

@Override
public boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType) {
  return sourceType.hasAnnotation(this.annotationType);
}

代码示例来源:origin: cn.bestwu.simpleframework/simpleframework-web

@Override
public boolean matches(TypeDescriptor typeDescriptor, TypeDescriptor typeDescriptor1) {
 return typeDescriptor1.hasAnnotation(KilogramToGram.class);
}

代码示例来源:origin: spring-cloud/spring-cloud-stream-app-starters

@Override
  public boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType) {
    return targetType.hasAnnotation(SupportsShorthands.class);
  }
}

代码示例来源:origin: cn.bestwu.simpleframework/simpleframework-web

@Override
public boolean matches(TypeDescriptor typeDescriptor, TypeDescriptor typeDescriptor1) {
 return typeDescriptor1.hasAnnotation(YuanToCent.class);
}

代码示例来源:origin: net.shibboleth.ext/spring-extensions

/** {@inheritDoc} */
@Override public boolean matches(final TypeDescriptor sourceType, final TypeDescriptor targetType) {
  return targetType.hasAnnotation(Duration.class);
}

代码示例来源:origin: apache/servicemix-bundles

@Override
public boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType) {
  return targetType.hasAnnotation(this.annotationType);
}

相关文章

微信公众号

最新文章

更多