javax.enterprise.inject.spi.AnnotatedConstructor Java Examples

The following examples show how to use javax.enterprise.inject.spi.AnnotatedConstructor. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: deltaspike   Author: apache   File: Annotateds.java    License: Apache License 2.0 6 votes vote down vote up
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;
}
 
Example #2
Source Project: deltaspike   Author: apache   File: AnnotatedTypeBuilderTest.java    License: Apache License 2.0 6 votes vote down vote up
@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()));
        }
    }
}
 
Example #3
Source Project: smallrye-fault-tolerance   Author: smallrye   File: FaultToleranceExtension.java    License: Apache License 2.0 4 votes vote down vote up
public Set<AnnotatedConstructor<T>> getConstructors() {
    return delegate.getConstructors();
}
 
Example #4
Source Project: smallrye-metrics   Author: smallrye   File: AnnotatedTypeDecorator.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public Set<AnnotatedConstructor<X>> getConstructors() {
    return decoratedType.getConstructors();
}
 
Example #5
Source Project: krazo   Author: eclipse-ee4j   File: AnnotatedTypeWrapper.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public Set<AnnotatedConstructor<T>> getConstructors() {
    return wrapped.getConstructors();
}
 
Example #6
Source Project: quarkus   Author: quarkusio   File: CurrentInjectionPointProvider.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public Set<AnnotatedConstructor<X>> getConstructors() {
    throw new UnsupportedOperationException();
}
 
Example #7
Source Project: ozark   Author: mvc-spec   File: AnnotatedTypeWrapper.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public Set<AnnotatedConstructor<T>> getConstructors() {
    return wrapped.getConstructors();
}
 
Example #8
Source Project: openwebbeans-meecrowave   Author: apache   File: AutoJpaAnnotationType.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public Set<AnnotatedConstructor<T>> getConstructors() {
    return delegate.getConstructors();
}
 
Example #9
Source Project: portals-pluto   Author: apache   File: ModifiedAnnotatedType.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public Set<AnnotatedConstructor<X>> getConstructors() {
	return annotatedType.getConstructors();
}
 
Example #10
Source Project: portals-pluto   Author: apache   File: PortletRequestScopedAnnotatedType.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public Set<AnnotatedConstructor<RequestScoped>> getConstructors() {
   return aType.getConstructors();
}
 
Example #11
Source Project: portals-pluto   Author: apache   File: PortletSessionScopedAnnotatedType.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public Set<AnnotatedConstructor<SessionScoped>> getConstructors() {
   return aType.getConstructors();
}
 
Example #12
Source Project: cxf   Author: apache   File: DelegateContextAnnotatedType.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public Set<AnnotatedConstructor<X>> getConstructors() {
    return original.getConstructors();
}
 
Example #13
Source Project: metrics-cdi   Author: astefanutti   File: AnnotatedTypeDecorator.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public Set<AnnotatedConstructor<X>> getConstructors() {
    return decoratedType.getConstructors();
}
 
Example #14
Source Project: deltaspike   Author: apache   File: Annotateds.java    License: Apache License 2.0 4 votes vote down vote up
public static <T> Comparator<AnnotatedConstructor<? super T>> instance()
{
    return new AnnotatedConstructorComparator<T>();
}
 
Example #15
Source Project: deltaspike   Author: apache   File: Annotateds.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * 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();
}
 
Example #16
Source Project: deltaspike   Author: apache   File: AnnotatedTypeImpl.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public Set<AnnotatedConstructor<X>> getConstructors()
{
    return Collections.unmodifiableSet(constructors);
}
 
Example #17
Source Project: deltaspike   Author: apache   File: AnnotatedTypeBuilder.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * 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);
}
 
Example #18
Source Project: deltaspike   Author: apache   File: AnnotatedTypeBuilder.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * 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);
}