if (dataType.equals("bigInteger")) {
value = new BigInteger((String) value);
} else if (dataType.equals("databaseFunction")) {
value = new DatabaseFunction((String) value);
} else {
throw new UnexpectedLiquibaseException("Unknown Data Type: " + dataType);
}
} catch (Throwable e) {
throw new UnexpectedLiquibaseException("Cannot convert string value '" + value + "' to " + dataType + ": " + e.getMessage());
}
}
try {
for (PropertyDescriptor descriptor : Introspector.getBeanInfo(change.getClass()).getPropertyDescriptors()) {
if (descriptor.getDisplayName().equals(this.parameterName)) {
Method writeMethod = descriptor.getWriteMethod();
if (writeMethod == null) {
throw new UnexpectedLiquibaseException("Could not find writeMethod for " + this.parameterName);
}
Class<?> expectedWriteType = writeMethod.getParameterTypes()[0];
if (value != null && !expectedWriteType.isAssignableFrom(value.getClass())) {
if (expectedWriteType.equals(String.class)) {
value = value.toString();
} else {
throw new UnexpectedLiquibaseException("Could not convert " + value.getClass().getName() + " to " + expectedWriteType.getName());
}
}
writeMethod.invoke(change, value);
}
}
} catch (Exception e) {
throw new UnexpectedLiquibaseException("Error setting " + this.parameterName + " to " + value, e);
}
}