All Downloads are FREE. Search and download functionalities are using the official Maven repository.

kikaha.core.cdi.helpers.DefaultFieldQualifierExtractor Maven / Gradle / Ivy

package kikaha.core.cdi.helpers;

import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.util.Collection;

import javax.enterprise.inject.Typed;
import javax.inject.Inject;
import javax.inject.Qualifier;

public class DefaultFieldQualifierExtractor implements FieldQualifierExtractor {

	@Override
	public boolean isAnnotatedWithQualifierAnnotation( Class ann ) {
		return ann.isAnnotationPresent( Qualifier.class );
	}

	@Override
	public boolean isASingleElementProvider( Field field ) {
		return field.isAnnotationPresent( Inject.class );
	}

	@Override
	public boolean isAManyElementsProvider( Field field ) {
		return isASingleElementProvider( field )
				&& fieldRepresentsACollection( field )
				&& field.isAnnotationPresent( Typed.class );
	}

	public static boolean fieldRepresentsACollection( final Field field ) {
		final Class type = field.getType();
		return Iterable.class.equals( type ) || Collection.class.equals( type );
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy