Java tutorial
//package com.java2s; // Licensed under the Apache License, Version 2.0 (the "License"); public class Main { public static <T> T as(Class<T> t, Object o) { return t.isInstance(o) ? t.cast(o) : null; } }