class ConverterTypeUtil {

    public static Object convert(Class<?> expectedClass, Object originalObject) {
        if (originalObject == null) {
            return null;
        }
        Class<?> currentClass = originalObject.getClass();
        if (expectedClass.isAssignableFrom(currentClass)) {
            return originalObject;
        }
        Object toReturn;
        if (currentClass.equals(String.class)) {
            try {
                toReturn = convertFromString(expectedClass, (String) originalObject);
            } catch (Exception e) {
                throw new KiePMMLException(String.format(FAILED_CONVERSION, originalObject,
                                                         expectedClass.getName()), e);
            }
        } else if (expectedClass == String.class) {
            toReturn = originalObject.toString();
        } else {
            throw new KiePMMLException(String.format(FAILED_CONVERSION, originalObject,
                                                     expectedClass.getName()));
        }
        return toReturn;
    }

    private  ConverterTypeUtil();

}