code: public static <T> T as(Object o, @NonNull Class<T> clazz) {
      try {
        return o == null ? null : clazz.cast(o);
      } catch (Exception e) {
        return null;
      }
    }
docs: Casts an object in a checked manner.
  
  @param <T>   the type parameter
  @param o     the object
  @param clazz The class to cast to
  @return the casted object or null if the object was null or the object was not of the desired type