/*
 * Copyright (C) 2004 - 2014 Brian McCallister
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.skife.jdbi.v2;

import org.skife.jdbi.v2.tweak.ResultColumnMapper;
import org.skife.jdbi.v2.tweak.ResultSetMapper;
import org.skife.jdbi.v2.util.*;

import java.math.BigDecimal;
import java.net.URL;
import java.sql.Timestamp;
import java.util.HashMap;
import java.util.Map;

/**
 * Result set mapper factory which knows how to construct java primitive types.
 */
public class PrimitivesMapperFactory implements ResultSetMapperFactory, ResultColumnMapperFactory
{
    private static final Map<Class, TypedMapper> mappers = new HashMap<Class, TypedMapper>();

    static {

        mappers.put(BigDecimal.class, BigDecimalMapper.FIRST);

        mappers.put(Boolean.class, BooleanMapper.FIRST);
        mappers.put(boolean.class, BooleanMapper.FIRST);

        mappers.put(byte[].class, ByteArrayMapper.FIRST);

        mappers.put(short.class, ShortMapper.FIRST);
        mappers.put(Short.class, ShortMapper.FIRST);

        mappers.put(Float.class, FloatMapper.FIRST);
        mappers.put(float.class, FloatMapper.FIRST);

        mappers.put(Double.class, DoubleMapper.FIRST);
        mappers.put(double.class, DoubleMapper.FIRST);

        mappers.put(Byte.class, ByteMapper.FIRST);
        mappers.put(byte.class, ByteMapper.FIRST);

        mappers.put(URL.class, URLMapper.FIRST);

        mappers.put(int.class, IntegerMapper.FIRST);
        mappers.put(Integer.class, IntegerMapper.FIRST);

        mappers.put(long.class, LongMapper.FIRST);
        mappers.put(Long.class, LongMapper.FIRST);

        mappers.put(Timestamp.class, TimestampMapper.FIRST);

        mappers.put(String.class, StringMapper.FIRST);
    }

    @Override
    public boolean accepts(Class type, StatementContext ctx)
    {
        return mappers.containsKey(type);
    }

    @Override
    public ResultSetMapper mapperFor(Class type, StatementContext ctx)
    {
        return mappers.get(type);
    }

    @Override
    public ResultColumnMapper columnMapperFor(Class type, StatementContext ctx) {
        return mappers.get(type);
    }
}

@@ -758,17 +758,558 @@
 v2.util.
-*
+BigDecimalMapper;%0Aimport org.skife.jdbi.v2.util.BooleanMapper;%0Aimport org.skife.jdbi.v2.util.ByteArrayMapper;%0Aimport org.skife.jdbi.v2.util.ByteMapper;%0Aimport org.skife.jdbi.v2.util.DoubleMapper;%0Aimport org.skife.jdbi.v2.util.FloatMapper;%0Aimport org.skife.jdbi.v2.util.IntegerMapper;%0Aimport org.skife.jdbi.v2.util.LongMapper;%0Aimport org.skife.jdbi.v2.util.ShortMapper;%0Aimport org.skife.jdbi.v2.util.StringMapper;%0Aimport org.skife.jdbi.v2.util.TimestampMapper;%0Aimport org.skife.jdbi.v2.util.TypedMapper;%0Aimport org.skife.jdbi.v2.util.URLMapper
 ;%0A%0Aimpor

Fix checkstyle violations: wildcard imports