001package com.hammurapi.convert; 002 003import java.util.Iterator; 004import java.util.concurrent.Callable; 005 006import com.hammurapi.common.Context; 007 008public class SingletonConverterPart implements ConverterPart { 009 010 @Override 011 public <S, T> T convert(S source, Class<T> targetType, Context context, Converter master) throws ConversionException { 012 if (source instanceof Iterable) { 013 Iterator it = ((Iterable) source).iterator(); 014 if (it.hasNext()) { 015 Object value = it.next(); 016 if (!it.hasNext()) { 017 return master.convert(value, targetType, context); 018 } 019 } 020 } 021 return null; 022 } 023 024}