package com.hammurapi.convert;

import java.util.concurrent.Future;

import com.hammurapi.common.Context;

public class FutureConverterPart implements ConverterPart {

	@Override
	public <S, T> T convert(S source, Class<T> targetType, Context context, Converter master) throws ConversionException {
		if (source instanceof Future) {
			try {
				Object value = ((Future) source).get();
				return master.convert(value, targetType, context);				
			} catch (Exception e) {
				throw new ConversionException(e);
			}
			
		}
		return null;
	}

}
