javax.enterprise.inject.spi.AnnotatedType.getFields()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(11.0k)|赞(0)|评价(0)|浏览(120)

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

AnnotatedType.getFields介绍

[英]Returns set of bean fields.
[中]返回一组bean字段。

代码示例

代码示例来源:origin: org.jboss.cdi.tck/cdi-tck-impl

private void validateManagedBean(AnnotatedType<Farm> type) {
  assert type.getBaseType().equals(Farm.class);
  assert typeSetMatches(type.getTypeClosure(), Farm.class, Object.class);
  assert type.getFields().size() == 1;
  assert type.getFields().iterator().next().isAnnotationPresent(Produces.class);
  assert type.getMethods().size() == 1;
  assert type.getMethods().iterator().next().isAnnotationPresent(Produces.class);
}

代码示例来源:origin: org.jboss.jsr299.tck/jsr299-tck-impl

private void validateManagedBean(AnnotatedType<Farm> type)
{
 assert type.getBaseType().equals(Farm.class);
 assert rawTypeSetMatches(type.getTypeClosure(), Farm.class, Object.class);
 assert type.getFields().size() == 1;
 assert type.getFields().iterator().next().isAnnotationPresent(Produces.class);
 assert type.getMethods().size() == 1;
 assert type.getMethods().iterator().next().isAnnotationPresent(Produces.class);
}

代码示例来源:origin: org.jboss.cdi.tck/cdi-tck-impl

private void validateTagLibraryListenerAnnotatedType(AnnotatedType<TagLibraryListener> type) {
  assertEquals(type.getBaseType(), TagLibraryListener.class);
  assertTrue(typeSetMatches(type.getTypeClosure(), TagLibraryListener.class, ServletContextListener.class,
      EventListener.class, Object.class));
  assertEquals(type.getFields().size(), 2);
  assertEquals(type.getConstructors().size(), 1);
  assertTrue(type.getMethods().stream().anyMatch(m -> m.getJavaMember().getName().equals("contextInitialized")));
}

代码示例来源:origin: org.jboss.cdi.tck/cdi-tck-impl

private void validateFilterAnnotatedType(AnnotatedType<TestFilter> type) {
  assertEquals(type.getBaseType(), TestFilter.class);
  assertTrue(typeSetMatches(type.getTypeClosure(), TestFilter.class, Filter.class, Object.class));
  assertEquals(type.getFields().size(), 12);
  assertEquals(type.getConstructors().size(), 1);
  assertTrue(type.getConstructors().iterator().next().getParameters().isEmpty());
  assertTrue(type.getMethods().stream().anyMatch(m -> m.getJavaMember().getName().equals("doFilter")));
}

代码示例来源:origin: org.jboss.jsr299.tck/jsr299-tck-impl

private void validateSessionBeanInterceptor(AnnotatedType<SheepInterceptor> type)
{
 assert type.getBaseType().equals(SheepInterceptor.class);
 assert rawTypeSetMatches(type.getTypeClosure(), SheepInterceptor.class, Object.class);
 assert type.getAnnotations().size() == 0;
 assert type.getFields().size() == 0;
 assert type.getMethods().size() == 1;
}

代码示例来源:origin: org.jboss.jsr299.tck/jsr299-tck-impl

private void validateTagLibraryListenerAnnotatedType(AnnotatedType<TagLibraryListener> type) {
 assert type.getBaseType().equals(TagLibraryListener.class);
 assert rawTypeSetMatches(type.getTypeClosure(), TagLibraryListener.class, ServletContextListener.class, EventListener.class, Object.class);
 assert type.getFields().size() == 2;
 assert type.getConstructors().size() == 1;
 assert type.getMethods().size() == 3;
}

代码示例来源:origin: org.jboss.cdi.tck/cdi-tck-impl

private void validateServletListenerAnnotatedType(AnnotatedType<TestListener> type) {
  assertEquals(type.getBaseType(), TestListener.class);
  assertTrue(type.getAnnotations().isEmpty());
  assertEquals(type.getFields().size(), 2);
  assertTrue(type.getMethods().stream().anyMatch(m -> m.getJavaMember().getName().equals("contextInitialized")));
  int initializers = 0;
  for (AnnotatedMethod<?> method : type.getMethods()) {
    assertEquals(method.getParameters().size(), 1);
    assertEquals(method.getBaseType(), void.class);
    if (method.isAnnotationPresent(Inject.class)) {
      initializers++;
    }
  }
  assertEquals(initializers, 1);
}

代码示例来源:origin: org.jboss.cdi.tck/cdi-tck-impl

private void validateSessionBeanInterceptor(AnnotatedType<SheepInterceptor> type) {
  assert type.getBaseType().equals(SheepInterceptor.class);
  assert typeSetMatches(type.getTypeClosure(), SheepInterceptor.class, Object.class);
  assert type.getAnnotations().size() == 0;
  assert type.getFields().size() == 0;
  assert type.getMethods().size() == 1;
}

代码示例来源:origin: weld/core

public AnnotatedTypeConfiguratorImpl(AnnotatedType<T> annotatedType) {
  super(annotatedType);
  this.constructors = annotatedType.getConstructors().stream().map(c -> AnnotatedConstructorConfiguratorImpl.from(c)).collect(ImmutableSet.collector());
  this.methods = annotatedType.getMethods().stream().map(m -> AnnotatedMethodConfiguratorImpl.from(m)).collect(ImmutableSet.collector());
  this.fields = annotatedType.getFields().stream().map(f -> AnnotatedFieldConfiguratorImpl.from(f)).collect(ImmutableSet.collector());
}

代码示例来源:origin: weld/core

public AnnotatedTypeConfiguratorImpl(AnnotatedType<T> annotatedType) {
  super(annotatedType);
  this.constructors = annotatedType.getConstructors().stream().map(c -> AnnotatedConstructorConfiguratorImpl.from(c)).collect(ImmutableSet.collector());
  this.methods = annotatedType.getMethods().stream().map(m -> AnnotatedMethodConfiguratorImpl.from(m)).collect(ImmutableSet.collector());
  this.fields = annotatedType.getFields().stream().map(f -> AnnotatedFieldConfiguratorImpl.from(f)).collect(ImmutableSet.collector());
}

代码示例来源:origin: org.jboss.weld.se/weld-se

/**
 * Generates a unique signature for an annotated type. Members without
 * annotations are omitted to reduce the length of the signature
 *
 * @param <X>
 * @param annotatedType
 * @return
 */
public static <X> String createTypeId(AnnotatedType<X> annotatedType) {
  return createTypeId(annotatedType.getJavaClass(), annotatedType.getAnnotations(), annotatedType.getMethods(), annotatedType.getFields(), annotatedType.getConstructors());
}

代码示例来源:origin: org.jboss.weld.se/weld-se-shaded

public AnnotatedTypeConfiguratorImpl(AnnotatedType<T> annotatedType) {
  super(annotatedType);
  this.constructors = annotatedType.getConstructors().stream().map(c -> AnnotatedConstructorConfiguratorImpl.from(c)).collect(ImmutableSet.collector());
  this.methods = annotatedType.getMethods().stream().map(m -> AnnotatedMethodConfiguratorImpl.from(m)).collect(ImmutableSet.collector());
  this.fields = annotatedType.getFields().stream().map(f -> AnnotatedFieldConfiguratorImpl.from(f)).collect(ImmutableSet.collector());
}

代码示例来源:origin: org.jboss.jsr299.tck/jsr299-tck-impl

private void validateFilterAnnotatedType(AnnotatedType<TestFilter> type) {
 assert type.getBaseType().equals(TestFilter.class);
 assert rawTypeSetMatches(type.getTypeClosure(), TestFilter.class, Filter.class, Object.class);
 assert type.getFields().size() == 4;
 assert type.getConstructors().size() == 1;
 assert type.getConstructors().iterator().next().getParameters().isEmpty();
 assert type.getMethods().size() == 4;
}

代码示例来源:origin: weld/core

public AnnotatedTypeConfiguratorImpl(AnnotatedType<T> annotatedType) {
  super(annotatedType);
  this.constructors = annotatedType.getConstructors().stream().map(c -> AnnotatedConstructorConfiguratorImpl.from(c)).collect(ImmutableSet.collector());
  this.methods = annotatedType.getMethods().stream().map(m -> AnnotatedMethodConfiguratorImpl.from(m)).collect(ImmutableSet.collector());
  this.fields = annotatedType.getFields().stream().map(f -> AnnotatedFieldConfiguratorImpl.from(f)).collect(ImmutableSet.collector());
}

代码示例来源:origin: org.jboss.weld.servlet/weld-servlet-shaded

public AnnotatedTypeConfiguratorImpl(AnnotatedType<T> annotatedType) {
  super(annotatedType);
  this.constructors = annotatedType.getConstructors().stream().map(c -> AnnotatedConstructorConfiguratorImpl.from(c)).collect(ImmutableSet.collector());
  this.methods = annotatedType.getMethods().stream().map(m -> AnnotatedMethodConfiguratorImpl.from(m)).collect(ImmutableSet.collector());
  this.fields = annotatedType.getFields().stream().map(f -> AnnotatedFieldConfiguratorImpl.from(f)).collect(ImmutableSet.collector());
}

代码示例来源:origin: org.jboss.cdi.tck/cdi-tck-impl

@Test
@SpecAssertions({ @SpecAssertion(section = BM_OBTAIN_ANNOTATEDTYPE, id = "a") })
public void testObtainingAnnotatedType() {
  AnnotatedType<?> annotatedType = getCurrentManager().createAnnotatedType(DerivedBean.class);
  assertTrue(annotatedType.isAnnotationPresent(Specializes.class));
  assertTrue(annotatedType.isAnnotationPresent(Tame.class));
  assertEquals(1, annotatedType.getFields().size());
  assertTrue(annotatedType.getMethods().isEmpty());
  assertEquals(3, annotatedType.getTypeClosure().size());
}

代码示例来源:origin: org.jboss.cdi.tck/cdi-tck-impl

@SuppressWarnings("unchecked")
private <X, A extends AnnotatedMember<? super X>> A getAnnotatedMember(Class<X> javaClass, String memberName) {
  AnnotatedType<X> type = getCurrentManager().createAnnotatedType(javaClass);
  for (AnnotatedField<? super X> field : type.getFields()) {
    if (field.getJavaMember().getName().equals(memberName)) {
      return (A) field;
    }
  }
  for (AnnotatedMethod<? super X> method : type.getMethods()) {
    if (method.getJavaMember().getName().equals(memberName)) {
      return (A) method;
    }
  }
  throw new IllegalArgumentException("Member " + memberName + " not found on " + javaClass);
}

代码示例来源:origin: org.jboss.forge/forge-addon-container

/**
* Generates a deterministic signature for an {@link AnnotatedType}. Two <code>AnnotatedType</code>s that have the
* same annotations and underlying type will generate the same signature.
* <p/>
* This can be used to create a unique bean id for a passivation capable bean that is added directly through the SPI.
* 
* @param annotatedType The type to generate a signature for
* @return A string representation of the annotated type
*/
public static <X> String createTypeId(AnnotatedType<X> annotatedType)
{
 return createTypeId(annotatedType.getJavaClass(), annotatedType.getAnnotations(), annotatedType.getMethods(),
      annotatedType.getFields(), annotatedType.getConstructors());
}

代码示例来源:origin: org.infinispan/infinispan-cdi

/**
 * Generates a deterministic signature for an {@link AnnotatedType}. Two
 * <code>AnnotatedType</code>s that have the same annotations and underlying
 * type will generate the same signature.
 * <p/>
 * This can be used to create a unique bean id for a passivation capable bean
 * that is added directly through the SPI.
 *
 * @param annotatedType The type to generate a signature for
 * @return A string representation of the annotated type
 */
public static <X> String createTypeId(AnnotatedType<X> annotatedType) {
  return createTypeId(annotatedType.getJavaClass(), annotatedType.getAnnotations(), annotatedType.getMethods(), annotatedType.getFields(), annotatedType.getConstructors());
}

代码示例来源:origin: org.jboss.forge.furnace/container-cdi-impl

/**
* Generates a deterministic signature for an {@link AnnotatedType}. Two <code>AnnotatedType</code>s that have the
* same annotations and underlying type will generate the same signature.
* <p/>
* This can be used to create a unique bean id for a passivation capable bean that is added directly through the SPI.
* 
* @param annotatedType The type to generate a signature for
* @return A string representation of the annotated type
*/
public static <X> String createTypeId(AnnotatedType<X> annotatedType)
{
 return createTypeId(annotatedType.getJavaClass(), annotatedType.getAnnotations(), annotatedType.getMethods(),
      annotatedType.getFields(), annotatedType.getConstructors());
}

相关文章