AbstractChainingFuture(ListenableFuture<? extends I> inputFuture, F function) { this.inputFuture = Preconditions.checkNotNull(inputFuture); this.function = Preconditions.checkNotNull(function); }
@Inject public GsonSourceParser(Gson gson, Type type) { checkNotNull(gson, "Gson can't be null"); checkNotNull(type, "Type can't be null"); this.gson = gson; this.type = type; }
private RemovalNotification( K key, V value, @Nonnull RemovalCause cause) { this.key = key; this.value = value; this.cause = checkNotNull(cause); }
/** * Use {@link MoreObjects#toStringHelper(Object)} to create an instance. */ private ToStringHelper(@Nonnull String className) { this.className = Preconditions.checkNotNull(className); }
@Override public void addListener(@Nonnull Runnable listener, @Nonnull Executor executor) { Preconditions.checkNotNull(listener, "Runnable was null."); Preconditions.checkNotNull(executor, "Executor was null."); try { executor.execute(listener); } catch (RuntimeException var4) { log.log(Level.SEVERE, "RuntimeException while executing runnable " + listener + " with executor " + executor, var4); } }
public MultiParser(List<KeyParser> parsers) { checkNotNull(parsers, "Parsers can't be null."); checkArgument(!parsers.isEmpty(), "Parsers can't be empty."); for (KeyParser parser : parsers) { checkNotNull(parser, "Parser can't be null."); } this.parsers.addAll(parsers); }
@Nullable @Override public V get(@Nonnull K key, @Nonnull final Callable<? extends V> valueLoader) throws ExecutionException { Preconditions.checkNotNull(valueLoader); return localCache.get(key, new CacheLoader<Object, V>() { @Override public V load(Object key) throws Exception { return valueLoader.call(); } }); }
@Nonnull public static <V> ListenableFuture<V> immediateFailedFuture(Throwable throwable) { Preconditions.checkNotNull(throwable); return new Futures.ImmediateFailedFuture<>(throwable); }
@Nonnull @Override public V load(@Nonnull Object key) { Preconditions.checkNotNull(key); return computingSupplier.get(); }
@Nonnull CacheBuilder<K, V> setValueStrength(@Nonnull LocalCache.Strength strength) { Preconditions.checkState(valueStrength == null, "Value strength was already set to %s", valueStrength); valueStrength = Preconditions.checkNotNull(strength); return this; }
@Nullable public ListenableFuture<V> reload(@Nonnull K key, @Nonnull V oldValue) throws Exception { Preconditions.checkNotNull(key); Preconditions.checkNotNull(oldValue); return Futures.immediateFuture(load(key)); }
@Nonnull ReferenceEntry<K, V> newEntry(@Nonnull K key, int hash, ReferenceEntry<K, V> next) { return map.entryFactory.newEntry(this, Preconditions.checkNotNull(key), hash, next); }
@Nonnull static <T> RepeatWhenEmits<T> from(@Nonnull Observable source) { return new RepeatWhenEmits<>(checkNotNull(source)); }
@Override public V get(long timeout, @Nonnull TimeUnit unit) throws ExecutionException { Preconditions.checkNotNull(unit); return this.get(); }
@Nonnull private ToStringHelper addHolder(@Nonnull String name, Object value) { ValueHolder valueHolder = addHolder(); valueHolder.value = value; valueHolder.name = Preconditions.checkNotNull(name); return this; }
@Nullable @Override public V putIfAbsent(@Nonnull K key, @Nonnull V value) { Preconditions.checkNotNull(key); Preconditions.checkNotNull(value); int hash = hash(key); return segmentFor(hash).put(key, hash, value, true); }
@Nullable @Override public V put(@Nonnull K key, @Nonnull V value) { Preconditions.checkNotNull(key); Preconditions.checkNotNull(value); int hash = hash(key); return segmentFor(hash).put(key, hash, value, false); }
@Nonnull public static <I, O> ListenableFuture<O> transform(@Nonnull ListenableFuture<I> input, Function<? super I, ? extends O> function) { Preconditions.checkNotNull(function); Futures.ChainingFuture<I,O> output = new Futures.ChainingFuture(input, function); input.addListener(output, DirectExecutor.INSTANCE); return output; }
/** * This method is a convenience for testing. Code should call {@link Segment#setValue} instead. */ // Guarded By Segment.this @Nonnull ValueReference<K, V> newValueReference(@Nonnull ReferenceEntry<K, V> entry, @Nonnull V value, int weight) { int hash = entry.getHash(); return valueStrength.referenceValue(segmentFor(hash), entry, Preconditions.checkNotNull(value), weight); }
void refresh(@Nonnull K key) { int hash = hash(Preconditions.checkNotNull(key)); segmentFor(hash).refresh(key, hash, defaultLoader, false); }