package com.google.gson.internal;
import java.lang.reflect.Type;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
public final class Primitives
{
private static final Map<Class<?>, Class<?>> PRIMITIVE_TO_WRAPPER_TYPE = Collections.unmodifiableMap(primToWrap);
private static final Map<Class<?>, Class<?>> WRAPPER_TO_PRIMITIVE_TYPE = Collections.unmodifiableMap(wrapToPrim);
private static void add(Map<Class<?>, Class<?>> forward, Map<Class<?>, Class<?>> backward, Class<?> key, Class<?> value)
{
forward.put(key, value);
backward.put(value, key);
}
public static boolean isPrimitive(Type type)
{
return PRIMITIVE_TO_WRAPPER_TYPE.containsKey(type);
}
public static <T> Class<T> wrap(Class<T> type)
{
Class wrapped = (Class)PRIMITIVE_TO_WRAPPER_TYPE.get(.Gson.Preconditions.checkNotNull(type));
return wrapped == null ? type : wrapped;
}
static
{
Map primToWrap = new HashMap(16);
Map wrapToPrim = new HashMap(16);
add(primToWrap, wrapToPrim, Boolean.TYPE, Boolean.class);
add(primToWrap, wrapToPrim, Byte.TYPE, Byte.class);
add(primToWrap, wrapToPrim, Character.TYPE, Character.class);
add(primToWrap, wrapToPrim, Double.TYPE, Double.class);
add(primToWrap, wrapToPrim, Float.TYPE, Float.class);
add(primToWrap, wrapToPrim, Integer.TYPE, Integer.class);
add(primToWrap, wrapToPrim, Long.TYPE, Long.class);
add(primToWrap, wrapToPrim, Short.TYPE, Short.class);
add(primToWrap, wrapToPrim, Void.TYPE, Void.class);
}
}