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

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

There is a newer version: 2.1.10.Final
Show newest version
package kikaha.core.cdi.helpers;

import java.lang.annotation.Annotation;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

import kikaha.core.cdi.ProviderContext;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;

@Getter
@Setter
@Accessors( fluent = true )
@RequiredArgsConstructor
public class KeyValueProviderContext implements ProviderContext {

	final Map, Annotation> annotationMap = new HashMap<>();
	final Map attributes;
	Class targetType;

	public KeyValueProviderContext() {
		attributes = new HashMap<>();
	}

	@Override
	@SuppressWarnings( "unchecked" )
	public  A getAnnotation( Class anntationClass ) {
		return (A)annotationMap.get( anntationClass );
	}

	public  void setAnnotation( Class anntationClass, A annotation ) {
		annotationMap.put( anntationClass, annotation );
	}

	public void attribute( Object key, Object value ) {
		attributes.put( key, value );
	}

	public  void attribute( Class key, T value ) {
		attributes.put( key.getCanonicalName(), value );
	}

	@Override
	public Object attribute( Object key ) {
		return attributes.get( key );
	}

	@Override
	@SuppressWarnings( "unchecked" )
	public  T attribute( Class key ) {
		return (T)attribute( key.getCanonicalName() );
	}

	@Override
	public Collection> qualifierAnnotations() {
		return Collections.emptyList();
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy