All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jsfr.json.provider.CastUtil Maven / Gradle / Ivy

The newest version!
package org.jsfr.json.provider;

final class CastUtil {

    private CastUtil() {
    }

    static  T castJavaObject(Object value, Class tClass) {
        if (tClass.isInstance(value) || value == null) {
            return tClass.cast(value);
        } else if (tClass == String.class) {
            return tClass.cast(value.toString());
        } else {
            throw new ClassCastException("Cannot cast " + value.getClass().getName() + " to " + tClass.getName());
        }
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy