Java Object Type Case cast(Object obj, Class clazz)

Here you can find the source of cast(Object obj, Class clazz)

Description

From a type point of view, this works ...

License

Open Source License

Declaration

public static <T> T cast(Object obj, Class<T> clazz) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    @SuppressWarnings("unchecked")
    public static <T> T cast(Object obj) {
        return (T) obj;
    }/*  w w w  .j a  v a2 s  .  c  o m*/

    /**
     * From a type point of view, this works ... however all call to this
     * function will perform the cast AFTER which sucks
     */
    public static <T> T cast(Object obj, Class<T> clazz) {
        return clazz.cast(obj);
    }
}

Related

  1. cast(Object inValue)
  2. cast(Object o)
  3. cast(Object o, Class clazz)
  4. cast(Object o, Class klass)
  5. cast(Object o, String clazz)
  6. cast(Object obj, Class type)
  7. cast(Object object)
  8. cast(Object object, Class targetClass)
  9. cast(Object source)