Package no.digipost.util.bisect
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
A suggested value for a bisection search. A
Suggestion is
AutoCloseable in order to support (if relevant) disposal
of dismissed values.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceA disposing operation for a dismissed value of aSuggestion. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()static <T> Suggestion<T>of(T value) Create a suggestion of a value.static <T> Suggestion<T>of(T value, Suggestion.Disposer<? super T> dismissedSuggestionDisposer) Create a suggestion of an object, with a custom operation fordisposingif the suggestion is dismissed.
-
Method Details
-
of
Create a suggestion of a value. If the given value isAutoCloseable, it will, if dismissed, it will have itsclose methodinvoked.- Returns:
- a new suggestion containing the given value
-
of
Create a suggestion of anAutoCloseableobject, which, if dismissed, will be disposed by having itsclose methodinvoked.- 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 fordisposingif the suggestion is dismissed.- Returns:
- a new suggestion containing the given value
-
close
- Specified by:
closein interfaceAutoCloseable- Throws:
Exception
-