Class Cast

java.lang.Object
dev.satyrn.papermc.api.util.v2.Cast

@Deprecated(since="1.9.0", forRemoval=true) public final class Cast extends Object
Deprecated, for removal: This API element is subject to removal in a future version.
Since 1.9.0 versioning refactor. To be removed in a future version. Use Cast instead.
Utility for safe-casting between objects.
Since:
1.6.0
Author:
Isabel Maskrey
  • Method Details

    • as

      @NotNull public static <T> @NotNull Optional<T> as(@NotNull @NotNull Class<T> asClass, @Nullable @Nullable Object object)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Safe-casts an object to another type.
      Type Parameters:
      T - The type that the object will be cast to.
      Parameters:
      asClass - The class to cast to.
      object - The object to cast.
      Returns:
      An optional of T where the result is only present if the cast succeeded.