package io.jboot.utils;

import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.math.BigInteger;
import java.util.List;
import java.util.Map;

public class TypeDef<T> {

    public static final TypeDef list_string = new TypeDef<List<String>>() {};
    public static final TypeDef list_integer = new TypeDef<List<Integer>>() {};
    public static final TypeDef list_biginteger = new TypeDef<List<BigInteger>>() {};

    public static final TypeDef map_string = new TypeDef<Map<String, String>>() {};
    public static final TypeDef map_integer = new TypeDef<Map<String, Integer>>() {};
    public static final TypeDef map_biginteger = new TypeDef<Map<String, BigInteger>>() {};


    protected Type type;
    protected Class defClass;

    protected TypeDef() {
        Type superClass = getClass().getGenericSuperclass();
        if (superClass == TypeDef.class) {
            throw new IllegalArgumentException("Must appoint generic class in TypeDef.");
        }

        Type type = ((ParameterizedType) superClass).getActualTypeArguments()[0];
        if (type instanceof ParameterizedType) {
            ParameterizedType paraType = (ParameterizedType) type;
            this.type = paraType;
            this.defClass = (Class) paraType.getRawType();
        } else {
            this.type = type;
            this.defClass = (Class) type;
        }
    }


    public Type getType() {
        return type;
    }


    public Class getDefClass() {
        return defClass;
    }

}

@@ -89,24 +89,53 @@
 flect.Type;%0A
+import java.math.BigDecimal;%0A
 import java.
@@ -260,19 +260,19 @@
 Def 
-list_string
+LIST_STRING
  = n
@@ -338,20 +338,20 @@
 Def 
-list_integer
+LIST_INTEGER
  = n
@@ -418,23 +418,23 @@
 Def 
-list_biginteger
+LIST_BIGINTEGER
  = n
@@ -468,17 +468,16 @@
 %3E() %7B%7D;%0A
-%0A
     publ
@@ -504,18 +504,105 @@
 Def 
-map_string
+LIST_BIGDECIMAL = new TypeDef%3CList%3CBigDecimal%3E%3E() %7B%7D;%0A%0A    public static final TypeDef MAP_STRING
  = n
@@ -675,19 +675,19 @@
 Def 
-map_integer
+MAP_INTEGER
  = n
@@ -761,22 +761,114 @@
 Def 
-map_biginteger
+MAP_BIGINTEGER = new TypeDef%3CMap%3CString, BigInteger%3E%3E() %7B%7D;%0A    public static final TypeDef MAP_BIGDECIMAL
  = n
@@ -885,39 +885,39 @@
 %3CMap%3CString, Big
-Integer
+Decimal
 %3E%3E() %7B%7D;%0A%0A%0A    p

optimize TypeDef