trip.spi.helpers.KeyValueProviderContext Maven / Gradle / Ivy
package trip.spi.helpers;
import java.lang.annotation.Annotation;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;
import trip.spi.ProviderContext;
@Getter
@Setter
@Accessors( fluent = true )
@RequiredArgsConstructor
public class KeyValueProviderContext implements ProviderContext {
final Map, Annotation> annotationMap = new HashMap, Annotation>();
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( String key, Object value ) {
attributes.put( key, value );
}
public void attribute( Class key, T value ) {
attributes.put( key.getCanonicalName(), value );
}
@Override
public Object attribute( String 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