package com.arondor.common.reflection.reflect.instantiator;

import java.util.HashMap;
import java.util.Map;

public class FastPrimitiveConverter
{
    private interface PrimitiveConverter
    {
        Object convert(String value);
    }

    private final Map<String, PrimitiveConverter> primitiveConverterMap = new HashMap<String, FastPrimitiveConverter.PrimitiveConverter>();

    public FastPrimitiveConverter()
    {
        primitiveConverterMap.put("java.lang.String", new PrimitiveConverter()
        {
            public Object convert(String value)
            {
                return value;
            }
        });
        primitiveConverterMap.put("long", new PrimitiveConverter()
        {
            public Object convert(String value)
            {
                return Long.parseLong(value);
            }
        });
        primitiveConverterMap.put("int", new PrimitiveConverter()
        {
            public Object convert(String value)
            {
                return Integer.parseInt(value);
            }
        });
    }

    public Object convert(String value, String primitiveClass)
    {
        PrimitiveConverter converter = primitiveConverterMap.get(primitiveClass);
        if (converter == null)
        {
            throw new IllegalArgumentException("Not supported : primitiveClass=" + primitiveClass);
        }
        return converter.convert(value);
    }
}

@@ -1042,24 +1042,244 @@
         %7D);%0A
+        primitiveConverterMap.put(%22boolean%22, new PrimitiveConverter()%0A        %7B%0A            public Object convert(String value)%0A            %7B%0A                return Boolean.parseBoolean(value);%0A            %7D%0A        %7D);%0A
     %7D%0A%0A    p

Add support for boolean type