Returns the parse {@link Function} with given class type.
Supports: {@link Byte}, {@link Short}, {@link Integer}, {@link Long},
{@link Float}, {@link Double}, {@link BigInteger}, {@link BigDecimal}, {@link Date}

@param type
@return
761648
public static <O> Function<Object, O> getParseFunction(Class<O> type) {
        return new StructBehavior<Function<Object, O>>(type) {

            @SuppressWarnings("unchecked")
            @Override protected Function<Object, O> booleanIf() {
                return (Function<Object, O>) TO_BOOLEAN; 
            }

            @SuppressWarnings("unchecked")
            @Override protected Function<Object, O> byteIf() {
                return (Function<Object, O>) TO_BYTE;
            }

            @SuppressWarnings("unchecked")
            @Override protected Function<Object, O> characterIf() {
                return (Function<Object, O>) TO_CHARACTER;
            }

            @SuppressWarnings("unchecked")
            @Override protected Function<Object, O> doubleIf() {
                return (Function<Object, O>) TO_DOUBLE;
            }

            @SuppressWarnings("unchecked")
            @Override protected Function<Object, O> floatIf() {
                return (Function<Object, O>) TO_FLOAT;
            }

            @SuppressWarnings("unchecked")
            @Override protected Function<Object, O> integerIf() {
                return (Function<Object, O>) TO_INTEGER;
            }

            @SuppressWarnings("unchecked")
            @Override protected Function<Object, O> longIf() {
                return (Function<Object, O>) TO_LONG;
            }

            @SuppressWarnings("unchecked")
            @Override protected Function<Object, O> shortIf() {
                return (Function<Object, O>) TO_SHORT;
            }

            @Override protected Function<Object, O> nullIf() {
                return null;
            }

            @Override protected Function<Object, O> noneMatched() {
                return new ValueBehaviorAdapter<Function<Object, O>>(delegate) {
                    
                    @SuppressWarnings("unchecked")
                    @Override protected Function<Object, O> dateIf(Date resolvedP) {
                        return (Function<Object, O>) TO_DATE;
                    }

                    @SuppressWarnings("unchecked")
                    @Override protected Function<Object, O> bigDecimalIf(BigDecimal resolvedP) {
                        return (Function<Object, O>) TO_BIGDECIMAL;
                    }

                    @SuppressWarnings("unchecked")
                    @Override protected Function<Object, O> bigIntegerIf(BigInteger resolvedP) {
                        return (Function<Object, O>) TO_BIGINTEGER;
                    }

                    @Override protected Function<Object, O> defaultBehavior() {
                        return null;
                    }
                }.doDetect();
            }
        }.doDetect();
    }
276980
@SuppressWarnings("unchecked")
    public <T> T readAsObject(byte[] content, Class<T> type) {
        try {
            if (content == null || content.length == 0 || type == null) {
                log.debug("content为{}，type为：{}", content, type);
                return null;
            } else if (type.equals(String.class)) {
                return (T) new String(content);
            }
            return MAPPER.readValue(content, type);
        } catch (Exception e) {
            log.error("json解析失败，失败原因：", e);
            return null;
        }
    }
1360358
private static Class<?> getActualRawType(Type type) {
        Class<?> rawType;
        if (type instanceof ParameterizedType) {
            rawType = (Class<?>) ((ParameterizedType) type).getRawType();
        } else {
            rawType = (Class<?>) type;
        }
        return rawType;
    }
1115096
public static Class<?> wrapper(Class<?> type) {
        if (type == null) {
            return null;
        }
        else if (type.isPrimitive()) {
            if (boolean.class == type) {
                return Boolean.class;
            }
            else if (int.class == type) {
                return Integer.class;
            }
            else if (long.class == type) {
                return Long.class;
            }
            else if (short.class == type) {
                return Short.class;
            }
            else if (byte.class == type) {
                return Byte.class;
            }
            else if (double.class == type) {
                return Double.class;
            }
            else if (float.class == type) {
                return Float.class;
            }
            else if (char.class == type) {
                return Character.class;
            }
            else if (void.class == type) {
                return Void.class;
            }
        }

        return type;
    }
735859
public static Object getCellValue(int type, Cell cell) {
        switch (type) {
            case Cell.CELL_TYPE_BOOLEAN:
                return cell.getBooleanCellValue();
            case Cell.CELL_TYPE_NUMERIC:
                if (DateUtil.isCellDateFormatted(cell)) {
                    return DateUtil.getJavaDate(cell.getNumericCellValue());
                } else {
                    BigDecimal bd = new BigDecimal(cell.getNumericCellValue());
                    return bd.toString().contains(".") ? bd.setScale(2, RoundingMode.HALF_UP).toString() :
                            bd.toString();
                }
            case Cell.CELL_TYPE_STRING:
                try {
                    return DateUtils.parseDate(cell.getStringCellValue(), ReadExcelUtils.PATTERN);
                } catch (Exception e) {
                    return cell.getStringCellValue();
                }
            case Cell.CELL_TYPE_FORMULA:
                if (DateUtil.isCellDateFormatted(cell)) {
                    return cell.getDateCellValue();
                }
                break;
            default:
                break;
        }
        return null;
    }
461264
function getTypeClass(type) {
  switch (type) {
    case String:
      return types.String;
    case Number:
      return types.Number;
    case Date:
      return types.Date;
    case Boolean:
      return types.Boolean;
    case Buffer:
      return types.Buffer;
  }

  if (typeof type === 'string') return types[type];

  for (const ii in types) {
    if (types[ii] === type) return types[ii];
  }
  return null;
}
933675
@SuppressWarnings("unckecked")
    public static Class<?> getRawType(Type type) {
        if (type instanceof Class<?>) {
            // type is a normal class.
            return (Class<?>) type;

        } else if (type instanceof ParameterizedType) {
            ParameterizedType parameterizedType = (ParameterizedType) type;

            // I'm not exactly sure why getRawType() returns Type instead of Class.
            // Neal isn't either but suspects some pathological case related
            // to nested classes exists.
            Type rawType = parameterizedType.getRawType();
            checkArgument(rawType instanceof Class,
                    "Expected a Class, but <%s> is of type %s", type, type.getClass().getName());
            //noinspection ConstantConditions
            return (Class<?>) rawType;

        } else if (type instanceof GenericArrayType) {
            Type componentType = ((GenericArrayType) type).getGenericComponentType();
            return Array.newInstance(getRawType(componentType), 0).getClass();

        } else if (type instanceof TypeVariable) {
            // we could use the variable's bounds, but that'll won't work if there are multiple.
            // having a raw type that's more general than necessary is okay
            return Object.class;

        } else {
            throw new IllegalArgumentException("Expected a Class, ParameterizedType, or "
                    + "GenericArrayType, but <" + type + "> is of type " + type.getClass().getName());
        }
    }
1176235
public <T> T get(Class<T> type) {
        return get(type.getName(), type);
    }
899853
public static Class<?> getRawType(Type type) {
		if (type instanceof Class<?>) {
			// type is a normal class.
			return (Class<?>) type;

		} else if (type instanceof ParameterizedType) {
			ParameterizedType parameterizedType = (ParameterizedType) type;

			// I'm not exactly sure why getRawType() returns Type instead of Class.
			// Neal isn't either but suspects some pathological case related
			// to nested classes exists.
			Type rawType = parameterizedType.getRawType();
			if (!(rawType instanceof Class)) {
				String message = MessageFormat.format("Expected a Class, but <{0}> is of type {1}", type, type.getClass()
						.getName());
				throw new IllegalArgumentException(message);
			}
			return (Class<?>) rawType;

		} else if (type instanceof GenericArrayType) {
			Type componentType = ((GenericArrayType) type).getGenericComponentType();
			return Array.newInstance(getRawType(componentType), 0).getClass();

		} else if (type instanceof TypeVariable) {
			// we could use the variable's bounds, but that'll won't work if there are multiple.
			// having a raw type that's more general than necessary is okay  
			return Object.class;

		} else {
			throw new IllegalArgumentException("Expected a Class, ParameterizedType, or " + "GenericArrayType, but <"
					+ type + "> is of type " + type.getClass().getName());
		}
	}
790455
public static DateTimeValue parse(Calendar cal, DateTimeType type) {

		int sYear = 0;
		int sMonthDay = 0;
		int sTime = 0;
		int sFractionalSecs = 0;
		boolean sPresenceTimezone = false;
		int sTimezone;

		switch (type) {
		case gYear: // gYear Year, [Time-Zone]
		case gYearMonth: // gYearMonth Year, MonthDay, [TimeZone]
		case date: // date Year, MonthDay, [TimeZone]
			sYear = cal.get(Calendar.YEAR);
			sMonthDay = getMonthDay(cal);
			break;
		case dateTime: // dateTime Year, MonthDay, Time, [FractionalSecs],
			// [TimeZone]
			sYear = cal.get(Calendar.YEAR);
			sMonthDay = getMonthDay(cal);
			// Note: *no* break;
		case time: // time Time, [FractionalSecs], [TimeZone]
			sTime = getTime(cal);
			sFractionalSecs = cal.get(Calendar.MILLISECOND);
			break;
		case gMonth: // gMonth MonthDay, [TimeZone]
		case gMonthDay: // gMonthDay MonthDay, [TimeZone]
		case gDay: // gDay MonthDay, [TimeZone]
			sMonthDay = getMonthDay(cal);
			break;
		default:
			throw new UnsupportedOperationException();
		}
		// [TimeZone]
		sTimezone = getTimeZoneInMinutesOffset(cal);
		if (sTimezone != 0) {
			sPresenceTimezone = true;
		}

		return new DateTimeValue(type, sYear, sMonthDay, sTime,
				sFractionalSecs, sPresenceTimezone, sTimezone);
	}
802596
public static Type toValueType(Type type) {
	if (type == Types.BYTE) return Types.BYTE_VALUE;
	if (type == Types.BOOLEAN) return Types.BOOLEAN_VALUE;
	if (type == Types.CHARACTER) return Types.CHAR;
	if (type == Types.DOUBLE) return Types.DOUBLE_VALUE;
	if (type == Types.FLOAT) return Types.FLOAT_VALUE;
	if (type == Types.INTEGER) return Types.INT_VALUE;
	if (type == Types.LONG) return Types.LONG_VALUE;
	if (type == Types.SHORT) return Types.SHORT_VALUE;

	return type;
    }
428663
public static String decodeObjectAndDate(String type) {
        return type.replace("object", Object.class.getName()).replace("date", Date.class.getName());
    }
1140609
public static boolean isPrimitiveType(Type type) {
	String className = type.getClassName();
	if (className.indexOf('.') != -1) return false;

	if ("boolean".equals(className)) return true;
	if ("short".equals(className)) return true;
	if ("float".equals(className)) return true;
	if ("long".equals(className)) return true;
	if ("double".equals(className)) return true;
	if ("char".equals(className)) return true;
	if ("int".equals(className)) return true;
	if ("byte".equals(className)) return true;

	return false;
    }
1373216
public static Op.Type getTypeFromByte(byte type) {
        switch (type) {
            case OpType.SCALAR:
                return Op.Type.SCALAR;
            case OpType.SCALAR_BOOL:
                return Op.Type.SCALAR_BOOL;
            case OpType.BROADCAST:
                return Op.Type.BROADCAST;
            case OpType.BROADCAST_BOOL:
                return Op.Type.BROADCAST_BOOL;
            case OpType.TRANSFORM_BOOL:
                return Op.Type.TRANSFORM_BOOL;
            case OpType.TRANSFORM_FLOAT:
                return Op.Type.TRANSFORM_FLOAT;
            case OpType.TRANSFORM_SAME:
                return Op.Type.TRANSFORM_SAME;
            case OpType.TRANSFORM_ANY:
                return Op.Type.TRANSFORM_ANY;
            case OpType.TRANSFORM_STRICT:
                return Op.Type.TRANSFORM_STRICT;
            case OpType.REDUCE_BOOL:
                return Op.Type.REDUCE_BOOL;
            case OpType.REDUCE_LONG:
                return Op.Type.REDUCE_LONG;
            case OpType.REDUCE_FLOAT:
                return Op.Type.REDUCE_FLOAT;
            case OpType.REDUCE_SAME:
                return Op.Type.REDUCE_SAME;
            case OpType.REDUCE_3:
                return Op.Type.REDUCE3;
            case OpType.INDEX_REDUCE:
                return Op.Type.INDEXREDUCE;
            case OpType.RANDOM:
                return Op.Type.RANDOM;
            case OpType.LOGIC:
                return Op.Type.META;
            case OpType.CUSTOM:
                return Op.Type.CUSTOM;
            case OpType.PAIRWISE:
                return Op.Type.PAIRWISE;
            case OpType.PAIRWISE_BOOL:
                return Op.Type.PAIRWISE_BOOL;
            case OpType.SUMMARYSTATS:
                return Op.Type.SUMMARYSTATS;
            default:
                throw new UnsupportedOperationException("Unknown op type passed in: " + type);
        }
    }
792582
public double read(final DataType type) throws IOException {
        if (type == null) {
            throw new NullPointerException("type must not be null.");
        }
        switch (type) {
            case CHAR:
                ensureAvailable(1);
                return buffer.get();
            case UCHAR:
                ensureAvailable(1);
                return ( (int) buffer.get() ) & 0x000000FF;
            case SHORT:
                ensureAvailable(2);
                return buffer.getShort();
            case USHORT:
                ensureAvailable(2);
                return ( (int) buffer.getShort() ) & 0x0000FFFF;
            case INT:
                ensureAvailable(4);
                return buffer.getInt();
            case UINT:
                ensureAvailable(4);
                return ( (long) buffer.getShort() ) & 0x00000000FFFFFFFF;
            case FLOAT:
                ensureAvailable(4);
                return buffer.getFloat();
            case DOUBLE:
                ensureAvailable(8);
                return buffer.getDouble();
            default:
                throw new IllegalArgumentException("Unsupported type: " + type);
        }
    }
339031
public static Class<?> rawClassOf(Type type) {
        if (type instanceof Class<?>) {
            return (Class<?>) type;
        } else if (type instanceof ParameterizedType) {
            ParameterizedType parameterizedType = (ParameterizedType) type;
            Type rawType = parameterizedType.getRawType();
            return (Class<?>) rawType;
        } else if (type instanceof GenericArrayType) {
            Type componentType = ((GenericArrayType) type).getGenericComponentType();
            return Array.newInstance(rawClassOf(componentType), 0).getClass();
        } else if (type instanceof TypeVariable) {
            return Object.class;
        } else {
            throw new IllegalArgumentException("Unsupported type " + type.getTypeName());
        }
    }
979822
public Object parse(String value, Class type)
    {
        if (StringUtil.isBlank(value))
        {
            return null;
        }

        return doConvert(value.trim(), type);
    }