Java 类javax.enterprise.inject.spi.AnnotatedConstructor 实例源码

项目:Camel    文件:CdiSpiHelper.java   
static boolean hasAnnotation(AnnotatedType<?> type, Class<? extends Annotation> annotation) {
    if (type.isAnnotationPresent(annotation)) {
        return true;
    }
    for (AnnotatedMethod<?> method : type.getMethods()) {
        if (method.isAnnotationPresent(annotation)) {
            return true;
        }
    }
    for (AnnotatedConstructor<?> constructor : type.getConstructors()) {
        if (constructor.isAnnotationPresent(annotation)) {
            return true;
        }
    }
    for (AnnotatedField<?> field : type.getFields()) {
        if (field.isAnnotationPresent(annotation)) {
            return true;
        }
    }
    return false;
}
项目:deltaspike    文件:Annotateds.java   
public int compare(AnnotatedConstructor<? super T> arg0, AnnotatedConstructor<? super T> arg1)
{
    int result = callableComparator.compare(arg0, arg1);
    if (result != 0)
    {
        return result;
    }
    for (int i = 0; i < arg0.getJavaMember().getParameterTypes().length; ++i)
    {
        Class<?> p0 = arg0.getJavaMember().getParameterTypes()[i];
        Class<?> p1 = arg1.getJavaMember().getParameterTypes()[i];
        result = p0.getName().compareTo(p1.getName());
        if (result != 0)
        {
            return result;
        }
    }
    return 0;
}
项目:deltaspike    文件:AnnotatedTypeBuilderTest.java   
@Test
public void modifyAnnotationsOnConstructorParameter() throws NoSuchMethodException
{
    final AnnotatedTypeBuilder<Cat> builder = new AnnotatedTypeBuilder<Cat>();
    builder.readFromType(Cat.class, true);
    builder.removeFromConstructorParameter(Cat.class.getConstructor(String.class, String.class), 1, Default.class);
    builder.addToConstructorParameter(Cat.class.getConstructor(String.class, String.class), 1, new AnyLiteral());

    final AnnotatedType<Cat> catAnnotatedType = builder.create();
    Set<AnnotatedConstructor<Cat>> catCtors = catAnnotatedType.getConstructors();

    assertThat(catCtors.size(), is(2));

    for (AnnotatedConstructor<Cat> ctor : catCtors)
    {
        if (ctor.getParameters().size() == 2)
        {
            List<AnnotatedParameter<Cat>> ctorParams = ctor.getParameters();

            assertThat(ctorParams.get(1).getAnnotations().size(), is(1));
            assertThat((AnyLiteral) ctorParams.get(1).getAnnotations().toArray()[0], is(new AnyLiteral()));
        }
    }
}
项目:aries-jpa    文件:ForwardingAnnotatedType.java   
@Override
public Set<AnnotatedConstructor<X>> getConstructors() {
    return delegate.getConstructors();
}
项目:ozark    文件:AnnotatedTypeWrapper.java   
@Override
public Set<AnnotatedConstructor<T>> getConstructors() {
    return wrapped.getConstructors();
}
项目:opendata-common    文件:MutableAnnotatedType.java   
@Override
public Set<AnnotatedConstructor<X>> getConstructors()
{
    return original.getConstructors();
}
项目:wildfly-swarm    文件:AnnotatedTypeDecorator.java   
@Override
public Set<AnnotatedConstructor<X>> getConstructors() {
    return decoratedType.getConstructors();
}
项目:wildfly-swarm    文件:HystrixExtension.java   
public Set<AnnotatedConstructor<T>> getConstructors() {
    return delegate.getConstructors();
}
项目:Camel    文件:AnnotatedTypeDelegate.java   
@Override
public Set<AnnotatedConstructor<T>> getConstructors() {
    return delegate.getConstructors();
}
项目:Camel    文件:AnnotatedTypeDecorator.java   
@Override
public Set<AnnotatedConstructor<X>> getConstructors() {
    return decoratedType.getConstructors();
}
项目:tapestry-jpa-transactions    文件:NoopAnnotatedType.java   
@Override
public Set<AnnotatedConstructor<X>> getConstructors()
{
    // TODO Auto-generated method stub
    return null;
}
项目:ocelot    文件:SpringConfigurationWrapper.java   
@Override
public Set<AnnotatedConstructor<T>> getConstructors() {
    return type.getConstructors();
}
项目:spearal-jpa2    文件:SpearalExtension.java   
public AnnotatedPersistenceUnitProducerType(Set<Annotation> annotations) throws Exception {
    this.annotations = annotations;
    this.annotatedConstructors = new HashSet<AnnotatedConstructor<PersistenceUnitProducer>>(); 
    this.annotatedConstructors.add(new AnnotatedPersistenceUnitProducerConstructor());
}
项目:spearal-jpa2    文件:SpearalExtension.java   
@Override
public Set<AnnotatedConstructor<PersistenceUnitProducer>> getConstructors() {
    return annotatedConstructors;
}
项目:portals-pluto    文件:PortletRequestScopedAnnotatedType.java   
@Override
public Set<AnnotatedConstructor<RequestScoped>> getConstructors() {
   return aType.getConstructors();
}
项目:portals-pluto    文件:PortletSessionScopedAnnotatedType.java   
@Override
public Set<AnnotatedConstructor<SessionScoped>> getConstructors() {
   return aType.getConstructors();
}
项目:metrics-cdi    文件:AnnotatedTypeDecorator.java   
@Override
public Set<AnnotatedConstructor<X>> getConstructors() {
    return decoratedType.getConstructors();
}
项目:deltaspike    文件:Annotateds.java   
public static <T> Comparator<AnnotatedConstructor<? super T>> instance()
{
    return new AnnotatedConstructorComparator<T>();
}
项目:deltaspike    文件:Annotateds.java   
/**
 * Generates a unique signature for a concrete class. Annotations are not
 * read directly from the class, but are read from the
 * <code>annotations</code>, <code>methods</code>, <code>fields</code> and
 * <code>constructors</code> arguments
 *
 * @param clazz        The java class type
 * @param annotations  Annotations present on the java class
 * @param methods      The AnnotatedMethods to include in the signature
 * @param fields       The AnnotatedFields to include in the signature
 * @param constructors The AnnotatedConstructors to include in the signature
 * @return A string representation of the type
 */
public static <X> String createTypeId(Class<X> clazz, Collection<Annotation> annotations,
                                      Collection<AnnotatedMethod<? super X>> methods,
                                      Collection<AnnotatedField<? super X>> fields,
                                      Collection<AnnotatedConstructor<X>> constructors)
{
    StringBuilder builder = new StringBuilder();

    builder.append(clazz.getName());
    builder.append(createAnnotationCollectionId(annotations));
    builder.append("{");

    // now deal with the fields
    List<AnnotatedField<? super X>> sortedFields = new ArrayList<AnnotatedField<? super X>>();
    sortedFields.addAll(fields);
    Collections.sort(sortedFields, AnnotatedFieldComparator.<X>instance());
    for (AnnotatedField<? super X> field : sortedFields)
    {
        if (!field.getAnnotations().isEmpty())
        {
            builder.append(createFieldId(field));
            builder.append(SEPARATOR);
        }
    }

    // methods
    List<AnnotatedMethod<? super X>> sortedMethods = new ArrayList<AnnotatedMethod<? super X>>();
    sortedMethods.addAll(methods);
    Collections.sort(sortedMethods, AnnotatedMethodComparator.<X>instance());
    for (AnnotatedMethod<? super X> method : sortedMethods)
    {
        if (!method.getAnnotations().isEmpty() || hasMethodParameters(method))
        {
            builder.append(createCallableId(method));
            builder.append(SEPARATOR);
        }
    }

    // constructors
    List<AnnotatedConstructor<? super X>> sortedConstructors = new ArrayList<AnnotatedConstructor<? super X>>();
    sortedConstructors.addAll(constructors);
    Collections.sort(sortedConstructors, AnnotatedConstructorComparator.<X>instance());
    for (AnnotatedConstructor<? super X> constructor : sortedConstructors)
    {
        if (!constructor.getAnnotations().isEmpty() || hasMethodParameters(constructor))
        {
            builder.append(createCallableId(constructor));
            builder.append(SEPARATOR);
        }
    }
    builder.append("}");

    return builder.toString();
}
项目:deltaspike    文件:AnnotatedTypeImpl.java   
/**
 * {@inheritDoc}
 */
@Override
public Set<AnnotatedConstructor<X>> getConstructors()
{
    return Collections.unmodifiableSet(constructors);
}
项目:deltaspike    文件:AnnotatedTypeBuilder.java   
/**
 * Add an annotation to the specified constructor. If the constructor is not
 * already present, it will be added.
 *
 * @param constructor the constructor to add the annotation to
 * @param annotation  the annotation to add
 * @throws IllegalArgumentException if the annotation is null
 */
public AnnotatedTypeBuilder<X> addToConstructor(AnnotatedConstructor<X> constructor, Annotation annotation)
{
    return addToConstructor(constructor.getJavaMember(), annotation);
}
项目:deltaspike    文件:AnnotatedTypeBuilder.java   
/**
 * Remove an annotation from the specified constructor.
 *
 * @param constructor    the constructor to add the annotation to
 * @param annotationType the annotation to add
 * @throws IllegalArgumentException if the annotationType is null, if the
 *                                  annotation does not exist on the type or if the constructor is
 *                                  not currently declared on the type
 */
public AnnotatedTypeBuilder<X> removeFromConstructor(AnnotatedConstructor<X> constructor,
                                                     Class<? extends Annotation> annotationType)
{
    return removeFromConstructor(constructor.getJavaMember(), annotationType);
}