code: public static <T> @NonNull Optional<T> cast(final @Nullable Object object, final @NonNull Class<T> type) {
      return type.isInstance(object) ? Optional.of((T) object) : Optional.empty();
    }
docs: Gets an optional of {@code object} if {@code object} is an instance of {@code type}, or an empty optional.
  
  @param object the object
  @param type the type
  @param <T> the type
  @return the optional