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

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

There is a newer version: 5.5.0
Show newest version
package com.hazelcast.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