Package org.apache.druid.common.guava
Class GuavaUtils
java.lang.Object
org.apache.druid.common.guava.GuavaUtils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <F extends Future<?>>
voidCancel futures manually, because sometime we can't cancel all futures in {code com.google.common.util.concurrent.Futures.CombinedFuture} automatically.static <T> TfirstNonNull(T lhs, T rhs) If first argument is not null, return it, else return the other argument.static <T extends Enum<T>>
TgetEnumIfPresent(Class<T> enumClass, String value) Like Guava's Enums.getIfPresent, with some differences.static LongtryParseLong(String string) To fix semantic difference of Longs.tryParse() from Long.parseLong (Longs.tryParse() returns null for '+' started value)
-
Constructor Details
-
GuavaUtils
public GuavaUtils()
-
-
Method Details
-
tryParseLong
To fix semantic difference of Longs.tryParse() from Long.parseLong (Longs.tryParse() returns null for '+' started value) -
getEnumIfPresent
Like Guava's Enums.getIfPresent, with some differences.- Returns nullable rather than Optional
- Does not require Guava 12
-
firstNonNull
@Nullable public static <T> T firstNonNull(@Nullable T lhs, @Nullable T rhs) If first argument is not null, return it, else return the other argument. Sort of likecom.google.common.base.Objects#firstNonNull(T, T)} except will not explode if both arguments are null.invalid @link
{@link <T> -
cancelAll
public static <F extends Future<?>> void cancelAll(boolean mayInterruptIfRunning, @Nullable Future<?> combinedFuture, List<F> futures) Cancel futures manually, because sometime we can't cancel all futures in {code com.google.common.util.concurrent.Futures.CombinedFuture} automatically. Especially when we callinvalid @link
{@link staticListenableFutureinvalid input: '<'List > com.google.common.util.concurrent.Futures#allAsList(Iterableinvalid input: '<'? extends ListenableFuture invalid input: '<'? extends V>> futures)} to create a batch of future. - Parameters:
mayInterruptIfRunning-trueif the thread executing this task should be interrupted; otherwise, in-progress tasks are allowed to completecombinedFuture- The combinedFuture that associated with futuresfutures- The futures that we want to cancel
-