|
@@ -23,64 +23,64 @@ public abstract class AbstractDataType<T> implements DataType {
|
|
|
parameterClazz = (Class<T>) ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0];
|
|
|
}
|
|
|
|
|
|
- protected T convertString(DataType dataType, Object val) {
|
|
|
- return throwUnsupportedException(dataType, val);
|
|
|
+ protected T convertString(Object val) {
|
|
|
+ return throwUnsupportedException(val);
|
|
|
}
|
|
|
|
|
|
- protected T convertByte(DataType dataType, Object val) {
|
|
|
- return throwUnsupportedException(dataType, val);
|
|
|
+ protected T convertByte(Object val) {
|
|
|
+ return throwUnsupportedException(val);
|
|
|
}
|
|
|
|
|
|
- protected T convertShort(DataType dataType, Object val) {
|
|
|
- return throwUnsupportedException(dataType, val);
|
|
|
+ protected T convertShort(Object val) {
|
|
|
+ return throwUnsupportedException(val);
|
|
|
}
|
|
|
|
|
|
- protected T convertInt(DataType dataType, Object val) {
|
|
|
- return throwUnsupportedException(dataType, val);
|
|
|
+ protected T convertInt(Object val) {
|
|
|
+ return throwUnsupportedException(val);
|
|
|
}
|
|
|
|
|
|
- protected T convertLong(DataType dataType, Object val) {
|
|
|
- return throwUnsupportedException(dataType, val);
|
|
|
+ protected T convertLong(Object val) {
|
|
|
+ return throwUnsupportedException(val);
|
|
|
}
|
|
|
|
|
|
- protected T convertDecimal(DataType dataType, Object val) {
|
|
|
- return throwUnsupportedException(dataType, val);
|
|
|
+ protected T convertDecimal(Object val) {
|
|
|
+ return throwUnsupportedException(val);
|
|
|
}
|
|
|
|
|
|
- protected T convertDouble(DataType dataType, Object val) {
|
|
|
- return throwUnsupportedException(dataType, val);
|
|
|
+ protected T convertDouble(Object val) {
|
|
|
+ return throwUnsupportedException(val);
|
|
|
}
|
|
|
|
|
|
- protected T convertFloat(DataType dataType, Object val) {
|
|
|
- return throwUnsupportedException(dataType, val);
|
|
|
+ protected T convertFloat(Object val) {
|
|
|
+ return throwUnsupportedException(val);
|
|
|
}
|
|
|
|
|
|
- protected T convertBoolean(DataType dataType, Object val) {
|
|
|
- return throwUnsupportedException(dataType, val);
|
|
|
+ protected T convertBoolean(Object val) {
|
|
|
+ return throwUnsupportedException(val);
|
|
|
}
|
|
|
|
|
|
- protected T convertDate(DataType dataType, Object val) {
|
|
|
- return throwUnsupportedException(dataType, val);
|
|
|
+ protected T convertDate(Object val) {
|
|
|
+ return throwUnsupportedException(val);
|
|
|
}
|
|
|
|
|
|
- protected T convertTime(DataType dataType, Object val) {
|
|
|
- return throwUnsupportedException(dataType, val);
|
|
|
+ protected T convertTime(Object val) {
|
|
|
+ return throwUnsupportedException(val);
|
|
|
}
|
|
|
|
|
|
- protected T convertTimeStamp(DataType dataType, Object val) {
|
|
|
- return throwUnsupportedException(dataType, val);
|
|
|
+ protected T convertTimeStamp(Object val) {
|
|
|
+ return throwUnsupportedException(val);
|
|
|
}
|
|
|
|
|
|
- protected T convertBytes(DataType dataType, Object val) {
|
|
|
- return throwUnsupportedException(dataType, val);
|
|
|
+ protected T convertBytes(Object val) {
|
|
|
+ return throwUnsupportedException(val);
|
|
|
}
|
|
|
|
|
|
- protected T convertArray(DataType dataType, Object val) {
|
|
|
- return throwUnsupportedException(dataType, val);
|
|
|
+ protected T convertArray(Object val) {
|
|
|
+ return throwUnsupportedException(val);
|
|
|
}
|
|
|
|
|
|
- protected T throwUnsupportedException(DataType dataType, Object val) {
|
|
|
- throw new SdkException(String.format("%s does not support type [%s] convert to [%s], val [%s]", getClass().getSimpleName(), val.getClass(), dataType.getType(), val));
|
|
|
+ protected T throwUnsupportedException(Object val) {
|
|
|
+ throw new SdkException(String.format("%s does not support type [%s] convert to [%s], val [%s]", getClass().getSimpleName(), val.getClass(), getType(), val));
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -93,8 +93,8 @@ public abstract class AbstractDataType<T> implements DataType {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Object convert(DataType dataType, Object val) {
|
|
|
- if (dataType == null || val == null) {
|
|
|
+ public Object convert(Object val) {
|
|
|
+ if (val == null) {
|
|
|
return getDefaultVal();
|
|
|
}
|
|
|
|
|
@@ -104,35 +104,35 @@ public abstract class AbstractDataType<T> implements DataType {
|
|
|
}
|
|
|
|
|
|
// 异构数据类型转换
|
|
|
- switch (dataType.getType()) {
|
|
|
+ switch (getType()) {
|
|
|
case STRING:
|
|
|
- return convertString(dataType, val);
|
|
|
+ return convertString(val);
|
|
|
case BYTE:
|
|
|
- return convertByte(dataType, val);
|
|
|
+ return convertByte(val);
|
|
|
case SHORT:
|
|
|
- return convertShort(dataType, val);
|
|
|
+ return convertShort(val);
|
|
|
case INT:
|
|
|
- return convertInt(dataType, val);
|
|
|
+ return convertInt(val);
|
|
|
case LONG:
|
|
|
- return convertLong(dataType, val);
|
|
|
+ return convertLong(val);
|
|
|
case DECIMAL:
|
|
|
- return convertDecimal(dataType, val);
|
|
|
+ return convertDecimal(val);
|
|
|
case DOUBLE:
|
|
|
- return convertDouble(dataType, val);
|
|
|
+ return convertDouble(val);
|
|
|
case FLOAT:
|
|
|
- return convertFloat(dataType, val);
|
|
|
+ return convertFloat(val);
|
|
|
case BOOLEAN:
|
|
|
- return convertBoolean(dataType, val);
|
|
|
+ return convertBoolean(val);
|
|
|
case DATE:
|
|
|
- return convertDate(dataType, val);
|
|
|
+ return convertDate(val);
|
|
|
case TIME:
|
|
|
- return convertTime(dataType, val);
|
|
|
+ return convertTime(val);
|
|
|
case TIMESTAMP:
|
|
|
- return convertTimeStamp(dataType, val);
|
|
|
+ return convertTimeStamp(val);
|
|
|
case BYTES:
|
|
|
- return convertBytes(dataType, val);
|
|
|
+ return convertBytes(val);
|
|
|
case ARRAY:
|
|
|
- return convertArray(dataType, val);
|
|
|
+ return convertArray(val);
|
|
|
default:
|
|
|
return getDefaultVal();
|
|
|
}
|