Class Suggestion<T>

java.lang.Object
no.digipost.util.bisect.Suggestion<T>
Type Parameters:
T - the type of the value contained in this suggestion
All Implemented Interfaces:
AutoCloseable

public final class Suggestion<T> extends Object implements AutoCloseable
A suggested value for a bisection search. A Suggestion is AutoCloseable in order to support (if relevant) disposal of dismissed values.
  • Method Details

    • of

      public static <T> Suggestion<T> of(T value)
      Create a suggestion of a value. If the given value is AutoCloseable, it will, if dismissed, it will have its close method invoked.
      Returns:
      a new suggestion containing the given value
    • of

      public static <T extends AutoCloseable> Suggestion<T> of(T value)
      Create a suggestion of an AutoCloseable object, which, if dismissed, will be disposed by having its close method invoked.
      Returns:
      a new suggestion containing the given value
    • of

      public static <T> Suggestion<T> of(T value, Suggestion.Disposer<? super T> dismissedSuggestionDisposer)
      Create a suggestion of an object, with a custom operation for disposing if the suggestion is dismissed.
      Returns:
      a new suggestion containing the given value
    • close

      public void close() throws Exception
      Specified by:
      close in interface AutoCloseable
      Throws:
      Exception