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

项目:property-inject    文件:PropertyFactory.java   
String getPropertyName(final InjectionPoint point, final String propertyName) {
    if (!propertyName.isEmpty()) {
        return propertyName;
    }

    Member member = point.getMember();
    final String name;

    if (member instanceof Executable) {
        Annotated annotated = point.getAnnotated();
        int p = ((AnnotatedParameter<?>) annotated).getPosition();
        name = member.getName() + ".arg" + p;
    } else {
        name = member.getName();
    }

    return name;
}
项目:property-inject    文件:PropertyProducerBeanTest.java   
@SuppressWarnings("unchecked")
private InjectionPoint mockInjectionPoint(Property property,
                                          Type type,
                                          Class<? extends Member> memberType,
                                          String memberName,
                                          int memberPosition) {
    InjectionPoint injectionPoint = mock(InjectionPoint.class);

    Member member = mock(memberType);
    when(injectionPoint.getType()).thenReturn(type);
    when(injectionPoint.getMember()).thenReturn(member);
    when(member.getName()).thenReturn(memberName);

    @SuppressWarnings("rawtypes")
    Bean mockBean = mock(Bean.class);
    when(injectionPoint.getBean()).thenReturn(mockBean);
    when(mockBean.getBeanClass()).thenReturn(getClass());

    AnnotatedParameter<?> annotated = mock(AnnotatedParameter.class);
    when(annotated.getPosition()).thenReturn(memberPosition);
    when(injectionPoint.getAnnotated()).thenReturn(annotated);

    when(annotated.getAnnotation(Property.class)).thenReturn(property);

    return injectionPoint;
}
项目:property-inject    文件:PropertyFactoryTest.java   
@SuppressWarnings("unchecked")
private InjectionPoint mockInjectionPoint(Property property,
                                          Class<? extends Member> memberType,
                                          String memberName,
                                          int memberPosition) {
    InjectionPoint injectionPoint = mock(InjectionPoint.class);

    Member member = mock(memberType);
    when(injectionPoint.getMember()).thenReturn(member);
    when(member.getName()).thenReturn(memberName);

    @SuppressWarnings("rawtypes")
    Bean mockBean = mock(Bean.class);
    when(injectionPoint.getBean()).thenReturn(mockBean);
    when(mockBean.getBeanClass()).thenReturn(getClass());

    AnnotatedParameter<?> annotated = mock(AnnotatedParameter.class);
    when(annotated.getPosition()).thenReturn(memberPosition);
    when(injectionPoint.getAnnotated()).thenReturn(annotated);

    when(annotated.getAnnotation(Property.class)).thenReturn(property);

    return injectionPoint;
}
项目:cdi-properties    文件:PropertyResolverMethodParametersVerifier.java   
/**
 * Checks if any property resolver method parameter is annotated with 
 * more than one of the following: {@link PropertyKey}, {@link PropertyBundle}, 
 * {@link PropertyLocale}
 */
private void checkMultipleAnnotationParameter() {
    int count;
    for (final AnnotatedParameter<?> parameter : propertyResolverMethod.getParameters()) {
        count = 0;
        if (parameter.isAnnotationPresent(PropertyKey.class)) {
            count++;
        }
        if (parameter.isAnnotationPresent(PropertyBundle.class)) {
            count++;
        }
        if (parameter.isAnnotationPresent(PropertyLocale.class)) {
            count++;
        }
        if (count > 1) {
            throw new ExtensionInitializationException(
                    "A property resolver method parameter must not be annotated with more than one of the following: "
                            + PropertyKey.class.getSimpleName() + ", " + PropertyBundle.class.getSimpleName()
                            + " or " + PropertyLocale.class.getSimpleName());
        }
    }
}
项目:deltaspike    文件:Annotateds.java   
/**
 * Generates a unique string representation of a list of
 * {@link AnnotatedParameter}s.
 */
public static <X> String createParameterListId(List<AnnotatedParameter<X>> parameters)
{
    StringBuilder builder = new StringBuilder();
    builder.append("(");
    for (int i = 0; i < parameters.size(); ++i)
    {
        AnnotatedParameter<X> ap = parameters.get(i);
        builder.append(createParameterId(ap));
        if (i + 1 != parameters.size())
        {
            builder.append(',');
        }
    }
    builder.append(")");
    return builder.toString();
}
项目:deltaspike    文件:Annotateds.java   
/**
 * Compares two annotated elements to see if they have the same annotations
 */
private static boolean compareAnnotatedParameters(List<? extends AnnotatedParameter<?>> p1,
                                                  List<? extends AnnotatedParameter<?>> p2)
{
    if (p1.size() != p2.size())
    {
        return false;
    }
    for (int i = 0; i < p1.size(); ++i)
    {
        if (!compareAnnotated(p1.get(i), p2.get(i)))
        {
            return false;
        }
    }
    return true;
}
项目:deltaspike    文件:AnnotatedTypeBuilder.java   
/**
 * Remove an annotation from the specified parameter.
 *
 * @param parameter      the parameter to remove the annotation from
 * @param annotationType the annotation type to remove
 * @throws IllegalArgumentException if the annotationType is null, if the
 *                                  callable which declares the parameter is not currently declared
 *                                  on the type or if the parameter is not declared on either a
 *                                  constructor or a method
 */
public AnnotatedTypeBuilder<X> removeFromParameter(AnnotatedParameter<? super X> parameter,
                                                   Class<? extends Annotation> annotationType)
{
    if (parameter.getDeclaringCallable().getJavaMember() instanceof Method)
    {
        Method method = (Method) parameter.getDeclaringCallable().getJavaMember();
        return removeFromMethodParameter(method, parameter.getPosition(), annotationType);
    }
    if (parameter.getDeclaringCallable().getJavaMember() instanceof Constructor<?>)
    {
        @SuppressWarnings("unchecked")
        Constructor<X> constructor = (Constructor<X>) parameter.getDeclaringCallable().getJavaMember();
        return removeFromConstructorParameter(constructor, parameter.getPosition(), annotationType);
    }
    else
    {
        throw new IllegalArgumentException("Cannot remove from parameter " + parameter +
                " - cannot operate on member " + parameter.getDeclaringCallable().getJavaMember());
    }
}
项目:deltaspike    文件:AnnotatedTypeBuilder.java   
/**
 * Add an annotation to the specified parameter. If the callable which
 * declares the parameter is not already present, it will be added. If the
 * parameter is not already present on the callable, it will be added.
 *
 * @param parameter  the parameter to add the annotation to
 * @param annotation the annotation to add
 * @throws IllegalArgumentException if the annotation is null or if the
 *                                  parameter is not declared on either a constructor or a method
 */
public AnnotatedTypeBuilder<X> addToParameter(AnnotatedParameter<? super X> parameter, Annotation annotation)
{
    if (parameter.getDeclaringCallable().getJavaMember() instanceof Method)
    {
        Method method = (Method) parameter.getDeclaringCallable().getJavaMember();
        return addToMethodParameter(method, parameter.getPosition(), annotation);
    }
    if (parameter.getDeclaringCallable().getJavaMember() instanceof Constructor<?>)
    {
        @SuppressWarnings("unchecked")
        Constructor<X> constructor = (Constructor<X>) parameter.getDeclaringCallable().getJavaMember();
        return addToConstructorParameter(constructor, parameter.getPosition(), annotation);
    }
    else
    {
        throw new IllegalArgumentException("Cannot remove from parameter " + parameter +
                " - cannot operate on member " + parameter.getDeclaringCallable().getJavaMember());
    }
}
项目:deltaspike    文件:AnnotatedTypeBuilder.java   
/**
 * Override the declared type of a parameter.
 *
 * @param parameter the parameter to override the type on
 * @param type      the new type of the parameter
 * @throws IllegalArgumentException if parameter or type is null
 */
public AnnotatedTypeBuilder<X> overrideParameterType(AnnotatedParameter<? super X> parameter, Type type)
{
    if (parameter.getDeclaringCallable().getJavaMember() instanceof Method)
    {
        Method method = (Method) parameter.getDeclaringCallable().getJavaMember();
        return overrideMethodParameterType(method, parameter.getPosition(), type);
    }
    if (parameter.getDeclaringCallable().getJavaMember() instanceof Constructor<?>)
    {
        @SuppressWarnings("unchecked")
        Constructor<X> constructor = (Constructor<X>) parameter.getDeclaringCallable().getJavaMember();
        return overrideConstructorParameterType(constructor, parameter.getPosition(), type);
    }
    else
    {
        throw new IllegalArgumentException("Cannot remove from parameter " + parameter +
                " - cannot operate on member " + parameter.getDeclaringCallable().getJavaMember());
    }
}
项目: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()));
        }
    }
}
项目:deltaspike    文件:HandlerMethodImpl.java   
/**
 * Determines if the given method is a handler by looking for the {@link Handles} annotation on a parameter.
 *
 * @param method method to search
 * @return true if {@link Handles} is found, false otherwise
 */
public static boolean isHandler(final AnnotatedMethod<?> method)
{
    if (method == null)
    {
        throw new IllegalArgumentException("Method must not be null");
    }

    for (AnnotatedParameter<?> param : method.getParameters())
    {
        if (param.isAnnotationPresent(Handles.class) || param.isAnnotationPresent(BeforeHandles.class))
        {
            return true;
        }
    }

    return false;
}
项目:deltaspike    文件:HandlerMethodImpl.java   
public static AnnotatedParameter<?> findHandlerParameter(final AnnotatedMethod<?> method)
{
    if (!isHandler(method))
    {
        throw new IllegalArgumentException("Method is not a valid handler");
    }

    AnnotatedParameter<?> returnParam = null;

    for (AnnotatedParameter<?> param : method.getParameters())
    {
        if (param.isAnnotationPresent(Handles.class) || param.isAnnotationPresent(BeforeHandles.class))
        {
            returnParam = param;
            break;
        }
    }

    return returnParam;
}
项目:deltaspike    文件:HandlerMethodImpl.java   
/**
 * Obtain all the injection points for the handler
 *
 * @param bm a BeanManager to use to obtain the beans
 */
public Set<InjectionPoint> getInjectionPoints(final BeanManager bm)
{
    if (injectionPoints == null)
    {
        injectionPoints = new HashSet<InjectionPoint>(handler.getParameters().size() - 1);

        for (AnnotatedParameter<?> param : handler.getParameters())
        {
            if (!param.equals(handlerParameter))
            {
                injectionPoints.add(
                        new ImmutableInjectionPoint(param, bm, getDeclaringBean(), false, false));
            }
        }

    }
    return new HashSet<InjectionPoint>(injectionPoints);
}
项目:weld-junit    文件:MockResourceInjectionServices.java   
private Resource getResourceAnnotation(InjectionPoint injectionPoint) {
    Annotated annotated = injectionPoint.getAnnotated();
    if (annotated instanceof AnnotatedParameter<?>) {
        annotated = ((AnnotatedParameter<?>) annotated).getDeclaringCallable();
    }
    return annotated.getAnnotation(Resource.class);
}
项目:reactive-cdi-events    文件:ReactorObserverRegistry.java   
public void process(Set<AnnotatedType<?>> discoveredTypes) {
    for(AnnotatedType<?> at : discoveredTypes) {
        for(AnnotatedMethod<?> am : at.getMethods()) {
            boolean hasObserver = am.getParameters().stream().anyMatch(ap -> ap.getAnnotation(ObservesReactor.class) != null);
            if(hasObserver) {
                AnnotatedParameter<?> observerType = am.getParameters().stream().filter(ap -> ap.isAnnotationPresent(ObservesReactor.class)).findFirst().orElseThrow(() -> new RuntimeException("No observer found"));
                Class<?> returnType = null;
                Type genericReturnType = am.getJavaMember().getGenericReturnType();
                boolean returnsPublisher = false;
                if(genericReturnType instanceof ParameterizedType) {
                    ParameterizedType type = (ParameterizedType)genericReturnType;
                    if(Publisher.class.isAssignableFrom((Class<?>) type.getRawType())) {
                        returnsPublisher = true;
                        returnType = (Class<?>) type.getActualTypeArguments()[0];
                    } else {
                        throw new RuntimeException("Method "+am+" should either return a concrete type or an instance of "+Publisher.class.getName());
                    }
                }
                else {
                    returnType = (Class)genericReturnType;
                }
                Class<?> eventType = observerType.getJavaParameter().getType();
                Set<Annotation> annotations = new LinkedHashSet<>(asList(observerType.getJavaParameter().getAnnotations()));
                methods.add(new ReactorMethod(at,am,returnType,eventType,annotations,returnsPublisher));
            }
        }
    }
}
项目:reactive-cdi-events    文件:ReactorObserverRegistry.java   
@Override
public Publisher<T> get(Object event) {
    CDI<Object> cdi = CDI.current();
    List<InstanceHolder> instanceHolders = new ArrayList<>();
    List<Object> parameters = new ArrayList<>();
    for(AnnotatedParameter<?> ap : annotatedMethod.getParameters()) {
        if(ap.isAnnotationPresent(ObservesReactor.class)) {
            parameters.add(event);
        } else {
            InstanceHolder holder = getReference(cdi, ap.getJavaParameter().getType(), ap.getAnnotations());
            instanceHolders.add(holder);
            parameters.add(holder.instance);
        }
    }
    InstanceHolder eventReceiver = getReference(cdi,annotatedType.getJavaClass(),
            findQualifiers(annotatedType.getAnnotations()));
    Object[] params = parameters.toArray();
    try {
        Object result = targetMethod.invoke(eventReceiver.instance, params);
        if(returnsPublisher) {
            return (Publisher<T>) result;
        } else {
            return Mono.just((T)result).doAfterTerminate(() -> instanceHolders.forEach(InstanceHolder::destroy));
        }
    } catch (IllegalAccessException | InvocationTargetException e) {
        return Mono.fromSupplier(() -> { throw new RuntimeException(e); });
    } finally {
        eventReceiver.destroy();
    }
}
项目:property-inject    文件:AbstractInjectionPointTest.java   
@SuppressWarnings("unchecked")
protected <T extends Annotation> InjectionPoint mockInjectionPoint(Class<T> annotationType,
                                                                   T annotation,
                                                                   Type type,
                                                                   Class<? extends Member> memberType,
                                                                   String memberName,
                                                                   int memberPosition) {
    InjectionPoint injectionPoint = mock(InjectionPoint.class);

    Member member = mock(memberType);
    when(injectionPoint.getType()).thenReturn(type);
    when(injectionPoint.getMember()).thenReturn(member);
    when(member.getName()).thenReturn(memberName);

    @SuppressWarnings("rawtypes")
    Bean mockBean = mock(Bean.class);
    when(injectionPoint.getBean()).thenReturn(mockBean);
    when(mockBean.getBeanClass()).thenReturn(getClass());

    AnnotatedParameter<?> annotated = mock(AnnotatedParameter.class);
    when(annotated.getPosition()).thenReturn(memberPosition);
    when(injectionPoint.getAnnotated()).thenReturn(annotated);

    when(annotated.getAnnotation(annotationType)).thenReturn(annotation);

    return injectionPoint;
}
项目:weld-vertx    文件:RouteExtension.java   
private boolean hasEventParameter(AnnotatedMethod<?> annotatedMethod) {
    for (AnnotatedParameter<?> param : annotatedMethod.getParameters()) {
        if (param.isAnnotationPresent(Observes.class)) {
            return true;
        }
    }
    return false;
}
项目:wildfly-swarm    文件:MetricCdiInjectionExtension.java   
private static boolean hasInjectionPointMetadata(AnnotatedMember<?> member) {
    if (!(member instanceof AnnotatedMethod)) {
        return false;
    }
    AnnotatedMethod<?> method = (AnnotatedMethod<?>) member;
    for (AnnotatedParameter<?> parameter : method.getParameters()) {
        if (parameter.getBaseType().equals(InjectionPoint.class)) {
            return true;
        }
    }
    return false;
}
项目:wildfly-swarm    文件:SeMetricName.java   
@Override
public String of(InjectionPoint ip) {
    Annotated annotated = ip.getAnnotated();
    if (annotated instanceof AnnotatedMember) {
        return of((AnnotatedMember<?>) annotated);
    } else if (annotated instanceof AnnotatedParameter) {
        return of((AnnotatedParameter<?>) annotated);
    } else {
        throw new IllegalArgumentException("Unable to retrieve metric name for injection point [" + ip + "], only members and parameters are supported");
    }
}
项目:wildfly-swarm    文件:SeMetricName.java   
private String of(AnnotatedParameter<?> parameter) {
    if (parameter.isAnnotationPresent(Metric.class)) {
        Metric metric = parameter.getAnnotation(Metric.class);
        String name = (metric.name().isEmpty()) ? getParameterName(parameter) : of(metric.name());
        return metric.absolute() | parameters.contains(MetricsParameter.useAbsoluteName) ? name : MetricRegistry.name(parameter.getDeclaringCallable().getJavaMember().getDeclaringClass(), name);
    } else {
        return parameters.contains(MetricsParameter.useAbsoluteName) ? getParameterName(parameter) : MetricRegistry.name(parameter.getDeclaringCallable().getJavaMember().getDeclaringClass(), getParameterName(parameter));
    }
}
项目:wildfly-swarm    文件:SeMetricName.java   
private String getParameterName(AnnotatedParameter<?> parameter) {
    try {
        Method method = Method.class.getMethod("getParameters");
        Object[] parameters = (Object[]) method.invoke(parameter.getDeclaringCallable().getJavaMember());
        Object param = parameters[parameter.getPosition()];
        Class<?> Parameter = Class.forName("java.lang.reflect.Parameter");
        if ((Boolean) Parameter.getMethod("isNamePresent").invoke(param)) {
            return (String) Parameter.getMethod("getName").invoke(param);
        } else {
            throw new UnsupportedOperationException("Unable to retrieve name for parameter [" + parameter + "], activate the -parameters compiler argument or annotate the injected parameter with the @Metric annotation");
        }
    } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException | ClassNotFoundException cause) {
        throw new UnsupportedOperationException("Unable to retrieve name for parameter [" + parameter + "], @Metric annotation on injected parameter is required before Java 8");
    }
}
项目:cdi-properties    文件:ProvidedResolverParameterExtractor.java   
/**
 * see {@link ResolverParameterExtractor#extract(AnnotatedParameter)}
 */
@Override
public T extract(AnnotatedParameter<?> parameter) {
    if (parameter.isAnnotationPresent(parameterType)) {
        return resolverParameter;
    }
    return null;
}
项目:cdi-properties    文件:DependentResolverMethodParametersVerifier.java   
/**
 * See {@link ResolverMethodVerifier#verify()}
 */
@Override
public void verify() {
    for (final AnnotatedParameter<?> parameter : resolverMethod.getParameters()) {
        if (checkDependentScope((Class<?>) parameter.getBaseType())) {
            checkPropertyField((Class<?>) parameter.getBaseType(), (Class<?>) parameter.getBaseType());
        }
    }
}
项目:cdi-properties    文件:LocaleResolverMethodParametersVerifier.java   
/**
 * Checks if any property resolver method parameter is annotated with 
 * {@link PropertyLocale}
 */
private void checkLocaleResolverParameterAnnotations() {
    for (final AnnotatedParameter<?> parameter : localeResolverMethod.getParameters()) {
        if (parameter.isAnnotationPresent(PropertyLocale.class)) {
            throw new ExtensionInitializationException(
                    "A Locale resolver method parameter must not be annotated with: "
                            + PropertyLocale.class.getSimpleName());
        }
    }
}
项目:cdi-properties    文件:PropertyResolverMethodParametersVerifier.java   
/**
 * Checks if there is at least one property resolver method parameter annotated with {@link PropertyKey}
 */
private void checkPropertyKeyExists() {
    boolean foundKeyProperty = false;
    for (final AnnotatedParameter<?> parameter : propertyResolverMethod.getParameters()) {
        if (parameter.isAnnotationPresent(PropertyKey.class)) {
            foundKeyProperty = true;
            break;
        }
    }
    if (!foundKeyProperty) {
        throw new ExtensionInitializationException(
                "At least one parameter of the custom property resolver must represent de property key, annotated with "
                        + PropertyKey.class.getName());
    }
}
项目:cdi-properties    文件:PropertyResolverMethodParametersVerifier.java   
/**
 * Checks if the given parameter type exists in more than a single property resolver
 * method parameter
 * @param annotation
 *            The parameter type being checked
 */
private void checkRepeatedParameterType(Class<? extends Annotation> annotation) {
    int count = 0;
    for (final AnnotatedParameter<?> parameter : propertyResolverMethod.getParameters()) {
        if (parameter.isAnnotationPresent(annotation)) {
            count++;
        }
    }
    if (count > 1) {
        throw new ExtensionInitializationException("There must be only a single param annotated with "
                + annotation.getSimpleName() + " in the property resolver method");
    }
}
项目:metrics-cdi    文件:MetricsExtension.java   
private static boolean hasInjectionPoints(AnnotatedMember<?> member) {
    if (!(member instanceof AnnotatedMethod))
        return false;
    AnnotatedMethod<?> method = (AnnotatedMethod<?>) member;
    for (AnnotatedParameter<?> parameter : method.getParameters()) {
        if (parameter.getBaseType().equals(InjectionPoint.class))
            return true;
    }
    return false;
}
项目:metrics-cdi    文件:SeMetricName.java   
@Override
public String of(InjectionPoint ip) {
    Annotated annotated = ip.getAnnotated();
    if (annotated instanceof AnnotatedMember)
        return of((AnnotatedMember<?>) annotated);
    else if (annotated instanceof AnnotatedParameter)
        return of((AnnotatedParameter<?>) annotated);
    else
        throw new IllegalArgumentException("Unable to retrieve metric name for injection point [" + ip + "], only members and parameters are supported");
}
项目:metrics-cdi    文件:SeMetricName.java   
private String of(AnnotatedParameter<?> parameter) {
    if (parameter.isAnnotationPresent(Metric.class)) {
        Metric metric = parameter.getAnnotation(Metric.class);
        String name = (metric.name().isEmpty()) ? getParameterName(parameter) : of(metric.name());
        return metric.absolute() | parameters.contains(useAbsoluteName) ? name : MetricRegistry.name(parameter.getDeclaringCallable().getJavaMember().getDeclaringClass(), name);
    } else {
        return parameters.contains(useAbsoluteName) ? getParameterName(parameter) : MetricRegistry.name(parameter.getDeclaringCallable().getJavaMember().getDeclaringClass(), getParameterName(parameter));
    }
}
项目:metrics-cdi    文件:SeMetricName.java   
private String getParameterName(AnnotatedParameter<?> parameter) {
    try {
        Method method = Method.class.getMethod("getParameters");
        Object[] parameters = (Object[]) method.invoke(parameter.getDeclaringCallable().getJavaMember());
        Object param = parameters[parameter.getPosition()];
        Class<?> Parameter = Class.forName("java.lang.reflect.Parameter");
        if ((Boolean) Parameter.getMethod("isNamePresent").invoke(param))
            return (String) Parameter.getMethod("getName").invoke(param);
        else
            throw new UnsupportedOperationException("Unable to retrieve name for parameter [" + parameter + "], activate the -parameters compiler argument or annotate the injected parameter with the @Metric annotation");
    } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException | ClassNotFoundException cause) {
        throw new UnsupportedOperationException("Unable to retrieve name for parameter [" + parameter + "], @Metric annotation on injected parameter is required before Java 8");
    }
}
项目:deltaspike    文件:Annotateds.java   
/**
 * Creates a deterministic signature for a {@link Method}.
 *
 * @param method      The method to generate the signature for
 * @param annotations The annotations to include in the signature
 * @param parameters  The {@link AnnotatedParameter}s to include in the
 *                    signature
 */
public static <X> String createMethodId(Method method, Set<Annotation> annotations,
                                        List<AnnotatedParameter<X>> parameters)
{
    StringBuilder builder = new StringBuilder();
    builder.append(method.getDeclaringClass().getName());
    builder.append('.');
    builder.append(method.getName());
    builder.append(createAnnotationCollectionId(annotations));
    builder.append(createParameterListId(parameters));
    return builder.toString();
}
项目:deltaspike    文件:Annotateds.java   
/**
 * Creates a deterministic signature for a {@link Constructor}.
 *
 * @param constructor The constructor to generate the signature for
 * @param annotations The annotations to include in the signature
 * @param parameters  The {@link AnnotatedParameter}s to include in the
 *                    signature
 */
public static <X> String createConstructorId(Constructor<X> constructor, Set<Annotation> annotations,
                                             List<AnnotatedParameter<X>> parameters)
{
    StringBuilder builder = new StringBuilder();
    builder.append(constructor.getDeclaringClass().getName());
    builder.append('.');
    builder.append(constructor.getName());
    builder.append(createAnnotationCollectionId(annotations));
    builder.append(createParameterListId(parameters));
    return builder.toString();
}
项目:deltaspike    文件:Annotateds.java   
private static <X> boolean hasMethodParameters(AnnotatedCallable<X> callable)
{
    for (AnnotatedParameter<X> parameter : callable.getParameters())
    {
        if (!parameter.getAnnotations().isEmpty())
        {
            return true;
        }
    }
    return false;
}
项目:deltaspike    文件:ImmutableInjectionPoint.java   
/**
 * Instantiate a new {@link InjectionPoint} based upon an
 * {@link AnnotatedParameter}.
 *
 * @param parameter     the parameter for which to create the injection point
 * @param qualifiers    the qualifiers on the injection point
 * @param declaringBean the declaringBean declaring the injection point
 * @param isTransient   <code>true</code> if the injection point is transient
 * @param delegate      <code>true</code> if the injection point is a delegate
 *                      injection point on a decorator
 */
public ImmutableInjectionPoint(AnnotatedParameter<?> parameter, Set<Annotation> qualifiers, Bean<?> declaringBean,
                               boolean isTransient, boolean delegate)
{
    annotated = parameter;
    member = parameter.getDeclaringCallable().getJavaMember();
    this.qualifiers = new HashSet<Annotation>(qualifiers);
    this.isTransient = isTransient;
    this.delegate = delegate;
    this.declaringBean = declaringBean;
    type = parameter.getBaseType();
}
项目:deltaspike    文件:ImmutableInjectionPoint.java   
/**
 * Instantiate a new {@link InjectionPoint} based upon an
 * {@link AnnotatedParameter}, reading the qualifiers from the annotations
 * declared on the parameter.
 *
 * @param parameter     the parameter for which to create the injection point
 * @param declaringBean the declaringBean declaring the injection point
 * @param isTransient   <code>true</code> if the injection point is transient
 * @param delegate      <code>true</code> if the injection point is a delegate
 *                      injection point on a decorator
 */
public ImmutableInjectionPoint(AnnotatedParameter<?> parameter, BeanManager beanManager, Bean<?> declaringBean,
                               boolean isTransient, boolean delegate)
{
    annotated = parameter;
    member = parameter.getDeclaringCallable().getJavaMember();
    qualifiers = BeanUtils.getQualifiers(beanManager, parameter.getAnnotations());
    this.isTransient = isTransient;
    this.delegate = delegate;
    this.declaringBean = declaringBean;
    type = parameter.getBaseType();
}
项目:deltaspike    文件:AnnotatedCallableImpl.java   
private static <X, Y extends Member> List<AnnotatedParameter<X>> getAnnotatedParameters(
        AnnotatedCallableImpl<X, Y> callable, Class<?>[] parameterTypes, Type[] genericTypes,
        Map<Integer, AnnotationStore> parameterAnnotations,
        Map<Integer, Type> parameterTypeOverrides)
{
    List<AnnotatedParameter<X>> parameters = new ArrayList<AnnotatedParameter<X>>();
    int len = parameterTypes.length;

    for (int i = 0; i < len; ++i)
    {
        AnnotationBuilder builder = new AnnotationBuilder();
        if (parameterAnnotations != null && parameterAnnotations.containsKey(i))
        {
            builder.addAll(parameterAnnotations.get(i));
        }
        Type over = null;
        if (parameterTypeOverrides != null)
        {
            over = parameterTypeOverrides.get(i);
        }
        AnnotatedParameterImpl<X> p = new AnnotatedParameterImpl<X>(
                callable, parameterTypes[i], i, builder.create(), genericTypes[i], over);

        parameters.add(p);
    }
    return parameters;
}
项目:deltaspike    文件:BeanUtils.java   
/**
 * Given a method, and the bean on which the method is declared, create a
 * collection of injection points representing the parameters of the method.
 *
 * @param <X>           the type declaring the method
 * @param method        the method
 * @param declaringBean the bean on which the method is declared
 * @param beanManager   the bean manager to use to create the injection points
 * @return the injection points
 */
public static <X> List<InjectionPoint> createInjectionPoints(AnnotatedMethod<X> method, Bean<?> declaringBean,
                                                             BeanManager beanManager)
{
    List<InjectionPoint> injectionPoints = new ArrayList<InjectionPoint>();
    for (AnnotatedParameter<X> parameter : method.getParameters())
    {
        InjectionPoint injectionPoint =
                new ImmutableInjectionPoint(parameter, beanManager, declaringBean, false, false);

        injectionPoints.add(injectionPoint);
    }
    return injectionPoints;
}
项目:ozark    文件:AnnotatedMethodWrapper.java   
@Override
public List<AnnotatedParameter<T>> getParameters() {
    return wrapped.getParameters();
}
项目:wildfly-swarm    文件:AnnotatedMethodDecorator.java   
@Override
public List<AnnotatedParameter<X>> getParameters() {
    return decoratedMethod.getParameters();
}