Here you can find the source of castNode(Class> jsonNode, Class
@SuppressWarnings("unchecked") public static <T> T castNode(Class<?> jsonNode, Class<T> classz) throws Exception
//package com.java2s; //License from project: Open Source License public class Main { @SuppressWarnings("unchecked") public static <T> T castNode(Class<?> jsonNode, Class<T> classz) throws Exception { if (classz.isAssignableFrom(jsonNode)) { return (T) classz; }//from www . j a v a 2s . com throw new ClassCastException("can not cast " + classz + " to " + jsonNode); } }