Skip to content

Commit

Permalink
extract out utility method for extracting qualifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
pmuir committed Jul 26, 2010
1 parent c7e5d4c commit 59a7d70
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 16 deletions.
42 changes: 42 additions & 0 deletions impl/src/main/java/org/jboss/weld/extensions/bean/Beans.java
@@ -0,0 +1,42 @@
package org.jboss.weld.extensions.bean;

import java.lang.annotation.Annotation;
import java.util.HashSet;
import java.util.Set;

import javax.enterprise.inject.spi.BeanManager;

public class Beans
{

private Beans() {}

public static Set<Annotation> getQualifiers(Iterable<Annotation> annotations, BeanManager beanManager)
{
Set<Annotation> qualifiers = new HashSet<Annotation>();
for (Annotation annotation : annotations)
{
if (beanManager.isQualifier(annotation.annotationType()))
{
qualifiers.add(annotation);
}
}
return qualifiers;
}

public static Set<Annotation> getQualifiers(Annotation[] annotations, BeanManager beanManager)
{
Set<Annotation> qualifiers = new HashSet<Annotation>();
for (Annotation annotation : annotations)
{
if (beanManager.isQualifier(annotation.annotationType()))
{
qualifiers.add(annotation);
}
}
return qualifiers;
}



}
Expand Up @@ -62,18 +62,11 @@ public InjectionPointImpl(AnnotatedField<?> field, BeanManager beanManager, Bean
{
this.annotated = field;
this.member = field.getJavaMember();
this.qualifiers = new HashSet<Annotation>();
this.qualifiers = Beans.getQualifiers(field.getAnnotations(), beanManager);
this.type = field.getJavaMember().getGenericType();
this._transient = trans;
this.delegate = delegate;
this.bean = bean;
for (Annotation a : field.getAnnotations())
{
if (beanManager.isQualifier(a.annotationType()))
{
qualifiers.add(a);
}
}
}

public InjectionPointImpl(AnnotatedParameter<?> param, Set<Annotation> qualifiers, Bean<?> bean, boolean trans, boolean delegate)
Expand All @@ -91,18 +84,11 @@ public InjectionPointImpl(AnnotatedParameter<?> param, BeanManager beanManager,
{
this.annotated = param;
this.member = param.getDeclaringCallable().getJavaMember();
this.qualifiers = new HashSet<Annotation>();
this.qualifiers = Beans.getQualifiers(param.getAnnotations(), beanManager);
this._transient = trans;
this.delegate = delegate;
this.bean = bean;
this.type = param.getBaseType();
for (Annotation a : annotated.getAnnotations())
{
if (beanManager.isQualifier(a.annotationType()))
{
qualifiers.add(a);
}
}
}

public Annotated getAnnotated()
Expand Down

0 comments on commit 59a7d70

Please sign in to comment.