/** * Returns a predicate that evaluates to {@code true} if both of its components evaluate to {@code * true}. The components are evaluated in order, and evaluation will be "short-circuited" as soon * as a false predicate is found. */ public static <T> Predicate<T> and(Predicate<? super T> first, Predicate<? super T> second) { return new AndPredicate<T>(Predicates.<T>asList(checkNotNull(first), checkNotNull(second))); }
@Override public <V> Optional<V> transform(Function<? super T, V> function) { return new Present<V>( checkNotNull( function.apply(reference), "the Function passed to Optional.transform() must not return null.")); }
@Override public String toString() { return toStringHelper(this) .add("lineNumber", lineNumber) .add("columnNumber", columnNumber) .toString(); } }
/** * Returns a predicate that evaluates to {@code true} if either of its components evaluates to * {@code true}. The components are evaluated in order, and evaluation will be "short-circuited" * as soon as a true predicate is found. */ public static <T> Predicate<T> or(Predicate<? super T> first, Predicate<? super T> second) { return new OrPredicate<T>(Predicates.<T>asList(checkNotNull(first), checkNotNull(second))); }
@Override public String toString() { return MoreObjects.toStringHelper(this).addValue(callback).toString(); } }
@Override public T or(Supplier<? extends T> supplier) { return checkNotNull( supplier.get(), "use Optional.orNull() instead of a Supplier that returns null"); }
@Override public <V> Optional<V> transform(Function<? super T, V> function) { checkNotNull(function); return Optional.absent(); }
/** * Returns a splitter that uses the given single-character separator. For example, {@code * Splitter.on(',').split("foo,,bar")} returns an iterable containing {@code ["foo", "", "bar"]}. * * @param separator the character to recognize as a separator * @return a splitter, with default settings, that recognizes that separator */ public static Splitter on(char separator) { return on(CharMatcher.is(separator)); }
/** * Returns a map joiner with the same behavior as this one, except automatically substituting * {@code nullText} for any provided null keys or values. */ public MapJoiner useForNull(String nullText) { return new MapJoiner(joiner.useForNull(nullText), keyValueSeparator); } }
@Override public final boolean hasNext() { checkState(state != State.FAILED); switch (state) { case READY: return true; case DONE: return false; default: } return tryToComputeNext(); }
private CompactStriped(int stripes, Supplier<L> supplier) { super(stripes); Preconditions.checkArgument(stripes <= Ints.MAX_POWER_OF_TWO, "Stripes must be <= 2^30)"); this.array = new Object[mask + 1]; for (int i = 0; i < array.length; i++) { array[i] = supplier.get(); } }
/** * Returns a new supplier which is the composition of the provided function and supplier. In other * words, the new supplier's value will be computed by retrieving the value from {@code supplier}, * and then applying {@code function} to that value. Note that the resulting supplier will not * call {@code supplier} or invoke {@code function} until it is called. */ public static <F, T> Supplier<T> compose(Function<? super F, T> function, Supplier<F> supplier) { Preconditions.checkNotNull(function); Preconditions.checkNotNull(supplier); return new SupplierComposition<>(function, supplier); }
/** * Returns a supplier whose {@code get()} method synchronizes on {@code delegate} before calling * it, making it thread-safe. */ public static <T> Supplier<T> synchronizedSupplier(Supplier<T> delegate) { return new ThreadSafeSupplier<T>(Preconditions.checkNotNull(delegate)); }
/** * Converts the specified {@code String str} from this format to the specified {@code format}. A * "best effort" approach is taken; if {@code str} does not conform to the assumed format, then * the behavior of this method is undefined but we make a reasonable effort at converting anyway. */ public final String to(CaseFormat format, String str) { checkNotNull(format); checkNotNull(str); return (format == this) ? str : convert(format, str); }
/** * Returns a predicate that evaluates to {@code true} if any one of its components evaluates to * {@code true}. The components are evaluated in order, and evaluation will be "short-circuited" * as soon as a true predicate is found. It defensively copies the iterable passed in, so future * changes to it won't alter the behavior of this predicate. If {@code components} is empty, the * returned predicate will always evaluate to {@code false}. */ public static <T> Predicate<T> or(Iterable<? extends Predicate<? super T>> components) { return new OrPredicate<T>(defensiveCopy(components)); }
@Override public String toString() { return toStringHelper(this) .add("subject", subject) .add("publicKey", publicKey) .toString(); } }
@Override public V load(Object key) { checkNotNull(key); return computingSupplier.get(); }
@Override public String toString() { return toStringHelper(this) .add("name", name) .add("oid", oid) .toString(); }