インターフェース ThrowingSupplier<T>

型パラメーター:
T - このサプライヤーが提供する結果の型
すべてのスーパーインターフェース:
SupplierSE<T>
すべての既知のサブインターフェース:
InstanceSupplier<T>
すべての既知の実装クラス:
BeanInstanceSupplier

public interface ThrowingSupplier<T> extends SupplierSE<T>
チェック例外をスローするコードの呼び出しを許可する SupplierSE
導入:
6.0
作成者:
Stephane Nicoll, Phillip Webb
  • メソッドの詳細

    • getWithException

      T getWithException() throws ExceptionSE
      結果を取得し、場合によってはチェック例外をスローします。
      戻り値:
      結果
      例外:
      ExceptionSE - エラー時
    • get

      default T get()
      スローされたチェック例外をラップするデフォルト Supplier.get() (デフォルトでは RuntimeExceptionSE 内)。
      次で指定:
      インターフェース SupplierSE<T>get 
      関連事項:
    • get

      default T get(BiFunctionSE<StringSE,ExceptionSE,RuntimeExceptionSE> exceptionWrapper)
      指定された exceptionWrapper を使用して、スローされたチェック例外をラップして、結果を取得します。
      パラメーター:
      exceptionWrapper - 指定されたメッセージとチェック済み例外を実行時例外にラップする BiFunctionSE
      戻り値:
      結果
    • throwing

      default ThrowingSupplier<T> throwing(BiFunctionSE<StringSE,ExceptionSE,RuntimeExceptionSE> exceptionWrapper)
      get() メソッドが、指定された exceptionWrapper を使用してスローされたチェック例外をラップする新しい ThrowingSupplier を返します。
      パラメーター:
      exceptionWrapper - 指定されたメッセージとチェック済み例外を実行時例外にラップする BiFunctionSE
      戻り値:
      置換 ThrowingSupplier インスタンス
    • of

      static <T> ThrowingSupplier<T> of(ThrowingSupplier<T> supplier)
      get() メソッドが、指定されたラムダ式またはメソッド参照によってスローされたチェック済み例外をラップする ThrowingSupplier を作成するために使用できる、ラムダに適した便利なメソッド。

      このメソッドは、メソッド参照を操作する場合に特に役立ちます。チェック例外をスローするメソッドを、通常の SupplierSE と互換性のあるインスタンスに簡単に変換できます。

      例:

       optional.orElseGet(ThrowingSupplier.of(Example::methodThatCanThrowCheckedException));
       
      型パラメーター:
      T - このサプライヤーが提供する結果の型
      パラメーター:
      supplier - ソースサプライヤー
      戻り値:
      新しい ThrowingSupplier インスタンス
    • of

      static <T> ThrowingSupplier<T> of(ThrowingSupplier<T> supplier, BiFunctionSE<StringSE,ExceptionSE,RuntimeExceptionSE> exceptionWrapper)
      get() メソッドが、指定された exceptionWrapper を使用して、スローされたチェック例外をラップする ThrowingSupplier を作成するために使用できる、ラムダに適した便利なメソッド。

      このメソッドは、メソッド参照を操作する場合に特に役立ちます。チェック例外をスローするメソッドを、通常の SupplierSE と互換性のあるインスタンスに簡単に変換できます。

      例:

       optional.orElseGet(ThrowingSupplier.of(Example::methodThatCanThrowCheckedException, IllegalStateException::new));
       
      型パラメーター:
      T - このサプライヤーが提供する結果の型
      パラメーター:
      supplier - ソースサプライヤー
      exceptionWrapper - 使用する例外ラッパー
      戻り値:
      新しい ThrowingSupplier インスタンス