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
public final class Suggestion<T> extends Object implements AutoCloseable
A suggested value for a bisection search. ASuggestionis AutoCloseable in order to support (if relevant)disposalof dismissed values.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceSuggestion.Disposer<T>A disposing operation for a dismissed value of aSuggestion.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()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 Detail
-
of
public static <T> Suggestion<T> of(T value)
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
public static <T extends AutoCloseable> Suggestion<T> of(T value)
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
public void close() throws Exception- Specified by:
closein interfaceAutoCloseable- Throws:
Exception
-
-