Here you can find the source of as(Class
public static <T> T as(Class<T> type, Object value)
//package com.java2s; //License from project: Apache License public class Main { public static <T> T as(Class<T> type, Object value) { if (type.isInstance(value)) { return type.cast(value); }/*from ww w .j av a 2 s . com*/ return null; } }