Class Nullables

java.lang.Object
net.minecraft.util.Nullables

public class Nullables extends Object
Contains utility methods that accept or return nullable values.
Mappings:
Namespace Name
named net/minecraft/util/Nullables
intermediary net/minecraft/class_8144
official x
  • Constructor Summary Link icon

    Constructors
    Constructor
    Description
     
  • Method Summary Link icon

    Modifier and Type
    Method
    Description
    static <T> T
    getFirst(Collection<T> collection)
    Returns the first element of collection, or null if it is empty.
    static <T> T
    getFirstOrElse(Collection<T> collection, T defaultValue)
    Returns the first element of collection, or defaultValue if it is empty.
    static <T> T
    getFirstOrElseGet(Collection<T> collection, Supplier<T> getter)
    Returns the first element of collection, or getter.get() if it is empty.
    static boolean
    isEmpty(@org.jetbrains.annotations.Nullable boolean[] array)
    Returns whether array is null or empty.
    static boolean
    isEmpty(@org.jetbrains.annotations.Nullable byte[] array)
    Returns whether array is null or empty.
    static boolean
    isEmpty(@org.jetbrains.annotations.Nullable char[] array)
    Returns whether array is null or empty.
    static boolean
    isEmpty(@org.jetbrains.annotations.Nullable double[] array)
    Returns whether array is null or empty.
    static boolean
    isEmpty(@org.jetbrains.annotations.Nullable float[] array)
    Returns whether array is null or empty.
    static boolean
    isEmpty(@org.jetbrains.annotations.Nullable int[] array)
    Returns whether array is null or empty.
    static boolean
    isEmpty(@org.jetbrains.annotations.Nullable long[] array)
    Returns whether array is null or empty.
    static boolean
    isEmpty(@org.jetbrains.annotations.Nullable short[] array)
    Returns whether array is null or empty.
    static <T> boolean
    isEmpty(T[] array)
    Returns whether array is null or empty.
    static <T, R> R
    map(T value, Function<T,R> mapper)
    Returns the value with mapper applied if the value is not null, otherwise null.
    static <T, R> R
    mapOrElse(T value, Function<T,R> mapper, R other)
    Returns the value with mapper applied if the value is not null, otherwise other.
    static <T, R> R
    mapOrElseGet(T value, Function<T,R> mapper, Supplier<R> getter)
    Returns the value with mapper applied if the value is not null, otherwise getter.get().

    Methods inherited from class java.lang.Object Link icon

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details Link icon

    • Nullables Link icon

      public Nullables()
  • Method Details Link icon

    • map Link icon

      @Nullable public static <T, R> R map(@Nullable T value, Function<T,R> mapper)
      Returns the value with mapper applied if the value is not null, otherwise null.

      This is the nullable equivalent to Optional.map(java.util.function.Function<? super T, ? extends U>).

      Returns:
      the value with mapper applied if the value is not null, otherwise null
      Mappings:
      Namespace Name Mixin selector
      named map Lnet/minecraft/util/Nullables;map(Ljava/lang/Object;Ljava/util/function/Function;)Ljava/lang/Object;
      intermediary method_49077 Lnet/minecraft/class_8144;method_49077(Ljava/lang/Object;Ljava/util/function/Function;)Ljava/lang/Object;
      official a Lx;a(Ljava/lang/Object;Ljava/util/function/Function;)Ljava/lang/Object;
    • mapOrElse Link icon

      public static <T, R> R mapOrElse(@Nullable T value, Function<T,R> mapper, R other)
      Returns the value with mapper applied if the value is not null, otherwise other.

      This is the nullable equivalent to Optional.map(java.util.function.Function<? super T, ? extends U>) chained with Optional.orElse(T).

      Returns:
      the value with mapper applied if the value is not null, otherwise other
      Mappings:
      Namespace Name Mixin selector
      named mapOrElse Lnet/minecraft/util/Nullables;mapOrElse(Ljava/lang/Object;Ljava/util/function/Function;Ljava/lang/Object;)Ljava/lang/Object;
      intermediary method_49078 Lnet/minecraft/class_8144;method_49078(Ljava/lang/Object;Ljava/util/function/Function;Ljava/lang/Object;)Ljava/lang/Object;
      official a Lx;a(Ljava/lang/Object;Ljava/util/function/Function;Ljava/lang/Object;)Ljava/lang/Object;
    • mapOrElseGet Link icon

      public static <T, R> R mapOrElseGet(@Nullable T value, Function<T,R> mapper, Supplier<R> getter)
      Returns the value with mapper applied if the value is not null, otherwise getter.get().

      This is the nullable equivalent to Optional.map(java.util.function.Function<? super T, ? extends U>) chained with Optional.orElseGet(java.util.function.Supplier<? extends T>).

      Returns:
      the value with mapper applied if the value is not null, otherwise getter.get()
      Mappings:
      Namespace Name Mixin selector
      named mapOrElseGet Lnet/minecraft/util/Nullables;mapOrElseGet(Ljava/lang/Object;Ljava/util/function/Function;Ljava/util/function/Supplier;)Ljava/lang/Object;
      intermediary method_49079 Lnet/minecraft/class_8144;method_49079(Ljava/lang/Object;Ljava/util/function/Function;Ljava/util/function/Supplier;)Ljava/lang/Object;
      official a Lx;a(Ljava/lang/Object;Ljava/util/function/Function;Ljava/util/function/Supplier;)Ljava/lang/Object;
    • getFirst Link icon

      @Nullable public static <T> T getFirst(Collection<T> collection)
      Returns the first element of collection, or null if it is empty.
      Returns:
      the first element of collection, or null if it is empty
      Mappings:
      Namespace Name Mixin selector
      named getFirst Lnet/minecraft/util/Nullables;getFirst(Ljava/util/Collection;)Ljava/lang/Object;
      intermediary method_49080 Lnet/minecraft/class_8144;method_49080(Ljava/util/Collection;)Ljava/lang/Object;
      official a Lx;a(Ljava/util/Collection;)Ljava/lang/Object;
    • getFirstOrElse Link icon

      public static <T> T getFirstOrElse(Collection<T> collection, T defaultValue)
      Returns the first element of collection, or defaultValue if it is empty.
      Returns:
      the first element of collection, or defaultValue if it is empty
      Mappings:
      Namespace Name Mixin selector
      named getFirstOrElse Lnet/minecraft/util/Nullables;getFirstOrElse(Ljava/util/Collection;Ljava/lang/Object;)Ljava/lang/Object;
      intermediary method_49081 Lnet/minecraft/class_8144;method_49081(Ljava/util/Collection;Ljava/lang/Object;)Ljava/lang/Object;
      official a Lx;a(Ljava/util/Collection;Ljava/lang/Object;)Ljava/lang/Object;
    • getFirstOrElseGet Link icon

      public static <T> T getFirstOrElseGet(Collection<T> collection, Supplier<T> getter)
      Returns the first element of collection, or getter.get() if it is empty.
      Returns:
      the first element of collection, or getter.get() if it is empty
      Mappings:
      Namespace Name Mixin selector
      named getFirstOrElseGet Lnet/minecraft/util/Nullables;getFirstOrElseGet(Ljava/util/Collection;Ljava/util/function/Supplier;)Ljava/lang/Object;
      intermediary method_49082 Lnet/minecraft/class_8144;method_49082(Ljava/util/Collection;Ljava/util/function/Supplier;)Ljava/lang/Object;
      official a Lx;a(Ljava/util/Collection;Ljava/util/function/Supplier;)Ljava/lang/Object;
    • isEmpty Link icon

      public static <T> boolean isEmpty(@Nullable T[] array)
      Returns whether array is null or empty.
      Returns:
      whether array is null or empty
      Mappings:
      Namespace Name Mixin selector
      named isEmpty Lnet/minecraft/util/Nullables;isEmpty([Ljava/lang/Object;)Z
      intermediary method_49089 Lnet/minecraft/class_8144;method_49089([Ljava/lang/Object;)Z
      official a Lx;a([Ljava/lang/Object;)Z
    • isEmpty Link icon

      public static boolean isEmpty(@Nullable @org.jetbrains.annotations.Nullable boolean[] array)
      Returns whether array is null or empty.
      Returns:
      whether array is null or empty
      Mappings:
      Namespace Name Mixin selector
      named isEmpty Lnet/minecraft/util/Nullables;isEmpty([Z)Z
      intermediary method_49091 Lnet/minecraft/class_8144;method_49091([Z)Z
      official a Lx;a([Z)Z
    • isEmpty Link icon

      public static boolean isEmpty(@Nullable @org.jetbrains.annotations.Nullable byte[] array)
      Returns whether array is null or empty.
      Returns:
      whether array is null or empty
      Mappings:
      Namespace Name Mixin selector
      named isEmpty Lnet/minecraft/util/Nullables;isEmpty([B)Z
      intermediary method_49083 Lnet/minecraft/class_8144;method_49083([B)Z
      official a Lx;a([B)Z
    • isEmpty Link icon

      public static boolean isEmpty(@Nullable @org.jetbrains.annotations.Nullable char[] array)
      Returns whether array is null or empty.
      Returns:
      whether array is null or empty
      Mappings:
      Namespace Name Mixin selector
      named isEmpty Lnet/minecraft/util/Nullables;isEmpty([C)Z
      intermediary method_49084 Lnet/minecraft/class_8144;method_49084([C)Z
      official a Lx;a([C)Z
    • isEmpty Link icon

      public static boolean isEmpty(@Nullable @org.jetbrains.annotations.Nullable short[] array)
      Returns whether array is null or empty.
      Returns:
      whether array is null or empty
      Mappings:
      Namespace Name Mixin selector
      named isEmpty Lnet/minecraft/util/Nullables;isEmpty([S)Z
      intermediary method_49090 Lnet/minecraft/class_8144;method_49090([S)Z
      official a Lx;a([S)Z
    • isEmpty Link icon

      public static boolean isEmpty(@Nullable @org.jetbrains.annotations.Nullable int[] array)
      Returns whether array is null or empty.
      Returns:
      whether array is null or empty
      Mappings:
      Namespace Name Mixin selector
      named isEmpty Lnet/minecraft/util/Nullables;isEmpty([I)Z
      intermediary method_49087 Lnet/minecraft/class_8144;method_49087([I)Z
      official a Lx;a([I)Z
    • isEmpty Link icon

      public static boolean isEmpty(@Nullable @org.jetbrains.annotations.Nullable long[] array)
      Returns whether array is null or empty.
      Returns:
      whether array is null or empty
      Mappings:
      Namespace Name Mixin selector
      named isEmpty Lnet/minecraft/util/Nullables;isEmpty([J)Z
      intermediary method_49088 Lnet/minecraft/class_8144;method_49088([J)Z
      official a Lx;a([J)Z
    • isEmpty Link icon

      public static boolean isEmpty(@Nullable @org.jetbrains.annotations.Nullable float[] array)
      Returns whether array is null or empty.
      Returns:
      whether array is null or empty
      Mappings:
      Namespace Name Mixin selector
      named isEmpty Lnet/minecraft/util/Nullables;isEmpty([F)Z
      intermediary method_49086 Lnet/minecraft/class_8144;method_49086([F)Z
      official a Lx;a([F)Z
    • isEmpty Link icon

      public static boolean isEmpty(@Nullable @org.jetbrains.annotations.Nullable double[] array)
      Returns whether array is null or empty.
      Returns:
      whether array is null or empty
      Mappings:
      Namespace Name Mixin selector
      named isEmpty Lnet/minecraft/util/Nullables;isEmpty([D)Z
      intermediary method_49085 Lnet/minecraft/class_8144;method_49085([D)Z
      official a Lx;a([D)Z