package com.prolog.rdc.tms.util;

import java.math.BigDecimal;
import java.math.BigInteger;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Date;

/**
 * 类属性type工具类
 *
 * @ClassName TypeUtil
 * @Author kh
 * @Date 1011/1/10 13:01
 * @Version V1.0
 **/
public class TypeUtil {

	/**
	 * 获取类属性的类型编码 1.数值、2字符、3日期、4.布尔、99其它
	 * 
	 * @param clazz
	 * @return {@link int}
	 * @throws @date 2022/1/20 14:09
	 */
	public static int getFieldTypeCode(Class<?> clazz) {

		if (clazz == byte.class || clazz == Byte.class) {
			return 10;
		}
		if (clazz == short.class || clazz == Short.class) {
			return 10;
		}
		if (clazz == int.class || clazz == Integer.class) {
			return 10;
		}
		if (clazz == long.class || clazz == Long.class) {
			return 10;
		}
		if (clazz == float.class || clazz == Float.class) {
			return 10;
		}
		if (clazz == double.class || clazz == Double.class) {
			return 10;
		}
		if (clazz == BigDecimal.class) {
			return 10;
		}
		if (clazz == BigInteger.class) {
			return 10;
		}
		if (clazz == char.class || clazz == Character.class) {
			return 20;
		}
		if (clazz == String.class) {
			return 20;
		}
		if (clazz == LocalDateTime.class) {
			return 30;
		}
		if (clazz == LocalDate.class) {
			return 30;
		}
		if (clazz == Date.class) {
			return 30;
		}
		if (clazz == java.sql.Date.class) {
			return 30;
		}
		if (clazz == java.sql.Timestamp.class) {
			return 30;
		}
		if (clazz == boolean.class || clazz == Boolean.class) {
			return 40;
		}

		return 99;
	}
}
