Java Object Type Case cast(Object source)

Here you can find the source of cast(Object source)

Description

cast

License

Apache License

Declaration

@SuppressWarnings("unchecked")
    public static <T> T cast(Object source) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    @SuppressWarnings("unchecked")
    public static <T> T cast(Object source) {
        try {//from  w  w  w.ja v a  2  s  . c o  m
            return source == null ? null : (T) source;
        } catch (Exception e) {
            throw new IllegalArgumentException("Cannot convert to type");
        }
    }
}

Related

  1. cast(Object o, String clazz)
  2. cast(Object obj, Class clazz)
  3. cast(Object obj, Class type)
  4. cast(Object object)
  5. cast(Object object, Class targetClass)
  6. cast(Object val, Class type)
  7. cast(Object value, String sqlType)
  8. cast(Object x)
  9. cast(Object x)