Java Object Type Case castNode(Class jsonNode, Class classz)

Here you can find the source of castNode(Class jsonNode, Class classz)

Description

cast Node

License

Open Source License

Declaration

@SuppressWarnings("unchecked")
    public static <T> T castNode(Class<?> jsonNode, Class<T> classz) throws Exception 

Method Source Code

//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);
    }
}

Related

  1. castForRegex(String textContent)
  2. castingNum(double n)
  3. castingUtil(String value, Class classCasting)
  4. castInstance(Object o, Class clazz)
  5. castInttoLong(int x)
  6. castNonNullArray( T [] arr)
  7. castNullableParameterTo(String parameterName, T value, Class requiredType)
  8. castNumber(Number num, Class clazz)
  9. castObject(Class clazz, Object object)