|
@@ -5,6 +5,7 @@ package org.dbsyncer.sdk.schema;
|
|
|
|
|
|
import org.dbsyncer.sdk.SdkException;
|
|
|
import org.dbsyncer.sdk.connector.ConnectorInstance;
|
|
|
+import org.dbsyncer.sdk.model.Field;
|
|
|
|
|
|
import java.lang.reflect.ParameterizedType;
|
|
|
|
|
@@ -15,7 +16,6 @@ import java.lang.reflect.ParameterizedType;
|
|
|
*/
|
|
|
public abstract class AbstractDataType<T> implements DataType {
|
|
|
|
|
|
- private static final long serialVersionUID = 1L;
|
|
|
private final Class<T> parameterClazz;
|
|
|
protected ConnectorInstance connectorInstance;
|
|
|
|
|
@@ -23,6 +23,15 @@ public abstract class AbstractDataType<T> implements DataType {
|
|
|
parameterClazz = (Class<T>) ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0];
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取默认值
|
|
|
+ *
|
|
|
+ * @return null
|
|
|
+ */
|
|
|
+ protected T getDefaultVal() {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
protected T convertString(Object val) {
|
|
|
return throwUnsupportedException(val);
|
|
|
}
|
|
@@ -83,13 +92,8 @@ public abstract class AbstractDataType<T> implements DataType {
|
|
|
throw new SdkException(String.format("%s does not support type [%s] convert to [%s], val [%s]", getClass().getSimpleName(), val.getClass(), getType(), val));
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 获取默认值
|
|
|
- *
|
|
|
- * @return null
|
|
|
- */
|
|
|
- protected Object getDefaultVal() {
|
|
|
- return null;
|
|
|
+ protected T throwUnsupportedException(Object val, Field field) {
|
|
|
+ throw new SdkException(String.format("%s does not support type [%s] convert to [%s], val [%s]", getClass().getSimpleName(), val.getClass(), field.getTypeName(), val));
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -138,6 +142,11 @@ public abstract class AbstractDataType<T> implements DataType {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public T convert(Object val, Field field) {
|
|
|
+ return throwUnsupportedException(val, field);
|
|
|
+ }
|
|
|
+
|
|
|
public ConnectorInstance getConnectorInstance() {
|
|
|
return connectorInstance;
|
|
|
}
|