类 OptionalMod<T>

java.lang.Object
net.minecraftforge.fml.OptionalMod<T>

public final class OptionalMod<T> extends Object
  • 字段概要

    字段
    修饰符和类型
    字段
    说明
    private static final OptionalMod<?>
     
    private final String
     
    private boolean
     
    private T
     
  • 构造器概要

    构造器
    限定符
    构造器
    说明
    private
    OptionalMod(boolean searched)
     
    private
     
  • 方法概要

    修饰符和类型
    方法
    说明
    private static <T> OptionalMod<T>
     
    boolean
     
    filter(Predicate<? super T> predicate)
    If a mod object is present, and the mod object matches the given predicate, return an OptionalMod describing the value, otherwise return an empty OptionalMod.
    <U> Optional<U>
    flatMap(Function<? super T,Optional<U>> mapper)
    If a value is present, apply the provided Optional-bearing mapping function to it, return that result, otherwise return an empty Optional.
    get()
    If a mod is present in this OptionalMod, returns the value, otherwise throws NoSuchElementException.
     
    private T
     
    int
     
    void
    ifPresent(Consumer<? super T> consumer)
    If a mod object is present, invoke the specified consumer with the object, otherwise do nothing.
    boolean
    Return true if there is a mod object present, otherwise false.
    <U> Optional<U>
    map(Function<? super T,? extends U> mapper)
    If a mod object is present, apply the provided mapping function to it, and if the result is non-null, return an Optional describing the result.
    static <M> OptionalMod<M>
    of(String modId)
     
    orElse(T other)
    Return the mod object if present, otherwise return other.
    orElseGet(Supplier<? extends T> other)
    Return the mod object if present, otherwise invoke other and return the result of that invocation.
    <X extends Throwable>
    T
    orElseThrow(Supplier<? extends X> exceptionSupplier)
    Return the contained mod object, if present, otherwise throw an exception to be created by the provided supplier.

    从类继承的方法 java.lang.Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • 字段详细资料

    • modId

      private final String modId
    • value

      private T value
    • searched

      private boolean searched
    • EMPTY

      private static final OptionalMod<?> EMPTY
  • 构造器详细资料

    • OptionalMod

      private OptionalMod(boolean searched)
    • OptionalMod

      private OptionalMod(String modId)
  • 方法详细资料

    • of

      public static <M> OptionalMod<M> of(String modId)
    • empty

      private static <T> OptionalMod<T> empty()
    • getValue

      private T getValue()
    • get

      public T get()
      If a mod is present in this OptionalMod, returns the value, otherwise throws NoSuchElementException.
      返回:
      the modobject held by this OptionalMod
      抛出:
      NoSuchElementException - if there is no modobject present
      另请参阅:
    • getModId

      public String getModId()
    • isPresent

      public boolean isPresent()
      Return true if there is a mod object present, otherwise false.
      返回:
      true if there is a mod object present, otherwise false
    • ifPresent

      public void ifPresent(Consumer<? super T> consumer)
      If a mod object is present, invoke the specified consumer with the object, otherwise do nothing.
      参数:
      consumer - block to be executed if a mod object is present
      抛出:
      NullPointerException - if mod object is present and consumer is null
    • filter

      public OptionalMod<T> filter(Predicate<? super T> predicate)
      If a mod object is present, and the mod object matches the given predicate, return an OptionalMod describing the value, otherwise return an empty OptionalMod.
      参数:
      predicate - a predicate to apply to the mod object, if present
      返回:
      an OptionalMod describing the value of this OptionalMod if a mod object is present and the mod object matches the given predicate, otherwise an empty OptionalMod
      抛出:
      NullPointerException - if the predicate is null
    • map

      public <U> Optional<U> map(Function<? super T,? extends U> mapper)
      If a mod object is present, apply the provided mapping function to it, and if the result is non-null, return an Optional describing the result. Otherwise return an empty Optional.
      类型参数:
      U - The type of the result of the mapping function
      参数:
      mapper - a mapping function to apply to the mod object, if present
      返回:
      an Optional describing the result of applying a mapping function to the mod object of this OptionalMod, if a mod object is present, otherwise an empty Optional
      抛出:
      NullPointerException - if the mapping function is null
      API Note:
      This method supports post-processing on optional values, without the need to explicitly check for a return status.
    • flatMap

      public <U> Optional<U> flatMap(Function<? super T,Optional<U>> mapper)
      If a value is present, apply the provided Optional-bearing mapping function to it, return that result, otherwise return an empty Optional. This method is similar to map(Function), but the provided mapper is one whose result is already an Optional, and if invoked, flatMap does not wrap it with an additional Optional.
      类型参数:
      U - The type parameter to the Optional returned by
      参数:
      mapper - a mapping function to apply to the mod object, if present the mapping function
      返回:
      the result of applying an Optional-bearing mapping function to the value of this Optional, if a value is present, otherwise an empty Optional
      抛出:
      NullPointerException - if the mapping function is null or returns a null result
    • orElse

      public T orElse(T other)
      Return the mod object if present, otherwise return other.
      参数:
      other - the mod object to be returned if there is no mod object present, may be null
      返回:
      the mod object, if present, otherwise other
    • orElseGet

      public T orElseGet(Supplier<? extends T> other)
      Return the mod object if present, otherwise invoke other and return the result of that invocation.
      参数:
      other - a Supplier whose result is returned if no mod object is present
      返回:
      the mod object if present otherwise the result of other.get()
      抛出:
      NullPointerException - if mod object is not present and other is null
    • orElseThrow

      public <X extends Throwable> T orElseThrow(Supplier<? extends X> exceptionSupplier) throws X
      Return the contained mod object, if present, otherwise throw an exception to be created by the provided supplier.
      类型参数:
      X - Type of the exception to be thrown
      参数:
      exceptionSupplier - The supplier which will return the exception to be thrown
      返回:
      the present mod object
      抛出:
      X - if there is no mod object present
      NullPointerException - if no mod object is present and exceptionSupplier is null
      API Note:
      A method reference to the exception constructor with an empty argument list can be used as the supplier. For example, IllegalStateException::new
    • equals

      public boolean equals(Object obj)
      覆盖:
      equals 在类中 Object
    • hashCode

      public int hashCode()
      覆盖:
      hashCode 在类中 Object