/*
 * Copyright 2015 Michael Rozumyanskiy
 *
 * 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 io.michaelrocks.lightsaber.processor.commons;

import org.apache.commons.collections4.BidiMap;
import org.apache.commons.collections4.bidimap.DualHashBidiMap;
import org.objectweb.asm.Type;

public class Types {
    private static final BidiMap<Type, Type> primitiveToBoxedMap;

    static {
        primitiveToBoxedMap = new DualHashBidiMap<>();
        primitiveToBoxedMap.put(Type.VOID_TYPE, Type.getType(Void.class));
        primitiveToBoxedMap.put(Type.BOOLEAN_TYPE, Type.getType(Boolean.class));
        primitiveToBoxedMap.put(Type.BYTE_TYPE, Type.getType(Byte.class));
        primitiveToBoxedMap.put(Type.CHAR_TYPE, Type.getType(Character.class));
        primitiveToBoxedMap.put(Type.DOUBLE_TYPE, Type.getType(Double.class));
        primitiveToBoxedMap.put(Type.FLOAT_TYPE, Type.getType(Float.class));
        primitiveToBoxedMap.put(Type.INT_TYPE, Type.getType(Integer.class));
        primitiveToBoxedMap.put(Type.LONG_TYPE, Type.getType(Long.class));
        primitiveToBoxedMap.put(Type.SHORT_TYPE, Type.getType(Short.class));
    }

    private Types() {
    }

    public static Type box(final Type type) {
        final Type boxedType = primitiveToBoxedMap.get(type);
        return boxedType != null ? boxedType : type;
    }

    public static Type unbox(final Type type) {
        final Type unboxedType = primitiveToBoxedMap.getKey(type);
        return unboxedType != null ? unboxedType : type;
    }

    public static boolean isPrimitive(final Type type) {
        return primitiveToBoxedMap.containsKey(type);
    }
}

@@ -818,16 +818,695 @@
 Types %7B%0A
+    public static final Type BOXED_VOID_TYPE = Type.getType(Byte.class);%0A    public static final Type BOXED_BOOLEAN_TYPE = Type.getType(Boolean.class);%0A    public static final Type BOXED_BYTE_TYPE = Type.getType(Byte.class);%0A    public static final Type BOXED_CHAR_TYPE = Type.getType(Character.class);%0A    public static final Type BOXED_DOUBLE_TYPE = Type.getType(Double.class);%0A    public static final Type BOXED_FLOAT_TYPE = Type.getType(Float.class);%0A    public static final Type BOXED_INT_TYPE = Type.getType(Integer.class);%0A    public static final Type BOXED_LONG_TYPE = Type.getType(Long.class);%0A    public static final Type BOXED_SHORT_TYPE = Type.getType(Short.class);%0A%0A
     priv
@@ -1684,32 +1684,23 @@
 PE, 
-Type.getType(Void.class)
+BOXED_VOID_TYPE
 );%0A 
@@ -1753,35 +1753,26 @@
 PE, 
-Type.getType(Boolean.class)
+BOXED_BOOLEAN_TYPE
 );%0A 
@@ -1822,32 +1822,23 @@
 PE, 
-Type.getType(Byte.class)
+BOXED_BYTE_TYPE
 );%0A 
@@ -1888,37 +1888,23 @@
 PE, 
-Type.getType(Character.class)
+BOXED_CHAR_TYPE
 );%0A 
@@ -1956,34 +1956,25 @@
 PE, 
-Type.getType(Double.class)
+BOXED_DOUBLE_TYPE
 );%0A 
@@ -2025,33 +2025,24 @@
 PE, 
-Type.getType(Float.class)
+BOXED_FLOAT_TYPE
 );%0A 
@@ -2091,35 +2091,22 @@
 PE, 
-Type.getType(Integer.class)
+BOXED_INT_TYPE
 );%0A 
@@ -2156,32 +2156,23 @@
 PE, 
-Type.getType(Long.class)
+BOXED_LONG_TYPE
 );%0A 
@@ -2223,33 +2223,24 @@
 PE, 
-Type.getType(Short.class)
+BOXED_SHORT_TYPE
 );%0A 

Add type constants for boxed primitives to Types