Refine search
/** * Returns whether {@link #lazyStackTrace} will use the special implementation described in its * documentation. * * @since 19.0 */ @Beta @GwtIncompatible // getStackTraceElementMethod public static boolean lazyStackTraceIsLazy() { return getStackTraceElementMethod != null && getStackTraceDepthMethod != null; }
/** * Returns a {@code ByteSink} that writes base-encoded bytes to the specified {@code CharSink}. */ @GwtIncompatible // ByteSink,CharSink public final ByteSink encodingSink(final CharSink encodedSink) { checkNotNull(encodedSink); return new ByteSink() { @Override public OutputStream openStream() throws IOException { return encodingStream(encodedSink.openStream()); } }; }
/** * Creates an {@link AsyncCallable} from a {@link Callable}. * * <p>The {@link AsyncCallable} returns the {@link ListenableFuture} resulting from {@link * ListeningExecutorService#submit(Callable)}. * * @since 20.0 */ @Beta @GwtIncompatible public static <T> AsyncCallable<T> asAsyncCallable( final Callable<T> callable, final ListeningExecutorService listeningExecutorService) { checkNotNull(callable); checkNotNull(listeningExecutorService); return new AsyncCallable<T>() { @Override public ListenableFuture<T> call() throws Exception { return listeningExecutorService.submit(callable); } }; }
/** * Returns a {@code ByteSource} that reads base-encoded bytes from the specified {@code * CharSource}. */ @GwtIncompatible // ByteSource,CharSource public final ByteSource decodingSource(final CharSource encodedSource) { checkNotNull(encodedSource); return new ByteSource() { @Override public InputStream openStream() throws IOException { return decodingStream(encodedSource.openStream()); } }; }
/** * A callback to be used with the streaming {@code readLines} methods. * * <p>{@link #processLine} will be called for each line that is read, and should return {@code * false} when you want to stop processing. * * @author Miles Barr * @since 1.0 */ @Beta @GwtIncompatible public interface LineProcessor<T> { /** * This method will be called once for each line. * * @param line the line read from the input, without delimiter * @return true to continue processing, false to stop */ @CanIgnoreReturnValue // some uses know that their processor never returns false boolean processLine(String line) throws IOException; /** Return the result of processing all the lines. */ T getResult(); }
@Beta @CanIgnoreReturnValue @GwtIncompatible // BlockingQueue public static <E> int drain( BlockingQueue<E> q, TimeUnit unit) throws InterruptedException { Preconditions.checkNotNull(buffer);
@GwtIncompatible // invokeAccessibleNonThrowingMethod private static List<StackTraceElement> jlaStackTrace(final Throwable t) { checkNotNull(t); /* * TODO(cpovirk): Consider optimizing iterator() to catch IOOBE instead of doing bounds checks. * * TODO(cpovirk): Consider the UnsignedBytes pattern if it performs faster and doesn't cause * AOSP grief. */ return new AbstractList<StackTraceElement>() { @Override public StackTraceElement get(int n) { return (StackTraceElement) invokeAccessibleNonThrowingMethod(getStackTraceElementMethod, jla, t, n); } @Override public int size() { return (Integer) invokeAccessibleNonThrowingMethod(getStackTraceDepthMethod, jla, t); } }; }
/** * Provides equivalent behavior to {@link String#intern} for other immutable types. Common * implementations are available from the {@link Interners} class. * * @author Kevin Bourrillion * @since 3.0 */ @Beta @GwtIncompatible public interface Interner<E> { /** * Chooses and returns the representative instance for any of a collection of instances that are * equal to each other. If two {@linkplain Object#equals equal} inputs are given to this method, * both calls will return the same instance. That is, {@code intern(a).equals(a)} always holds, * and {@code intern(a) == intern(b)} if and only if {@code a.equals(b)}. Note that {@code * intern(a)} is permitted to return one instance now and a different instance later if the * original interned instance was garbage-collected. * * <p><b>Warning:</b> do not use with mutable objects. * * @throws NullPointerException if {@code sample} is null */ @CanIgnoreReturnValue // TODO(cpovirk): Consider removing this? E intern(E sample); }
@Beta @CanIgnoreReturnValue @GwtIncompatible // BlockingQueue public static <E> int drainUninterruptibly( BlockingQueue<E> q, long timeout, TimeUnit unit) { Preconditions.checkNotNull(buffer); long deadline = System.nanoTime() + unit.toNanos(timeout); int added = 0;
/** @since 12.0 */ @GwtIncompatible // NavigableSet @Override public ContiguousSet<C> headSet(C toElement, boolean inclusive) { return headSetImpl(checkNotNull(toElement), inclusive); }
/** * A callback interface to process bytes from a stream. * * <p>{@link #processBytes} will be called for each chunk of data that is read, and should return * {@code false} when you want to stop processing. * * @author Chris Nokleberg * @since 1.0 */ @Beta @GwtIncompatible public interface ByteProcessor<T> { /** * This method will be called for each chunk of bytes in an input stream. The implementation * should process the bytes from {@code buf[off]} through {@code buf[off + len - 1]} (inclusive). * * @param buf the byte array containing the data to process * @param off the initial offset into the array * @param len the length of data to be processed * @return true to continue processing, false to stop */ @CanIgnoreReturnValue // some uses know that their processor never returns false boolean processBytes(byte[] buf, int off, int len) throws IOException; /** Return the result of processing all the bytes. */ T getResult(); }
@Beta @GwtIncompatible // NavigableSet public static <K extends Comparable<? super K>> NavigableSet<K> subSet( NavigableSet<K> set, Range<K> range) { return set.headSet(range.upperEndpoint(), range.upperBoundType() == BoundType.CLOSED); return checkNotNull(set);
/** @since 12.0 */ @GwtIncompatible // NavigableSet @Override public ContiguousSet<C> tailSet(C fromElement, boolean inclusive) { return tailSetImpl(checkNotNull(fromElement), inclusive); }
@Beta @GwtIncompatible public interface ListeningScheduledExecutorService extends ScheduledExecutorService, ListeningExecutorService {
@Beta @GwtIncompatible // NavigableMap public static <K extends Comparable<? super K>, V> NavigableMap<K, V> subMap( NavigableMap<K, V> map, Range<K> range) { return map.headMap(range.upperEndpoint(), range.upperBoundType() == BoundType.CLOSED); return checkNotNull(map);
/** * Returns the result of multiplying this and {@code val}. If the result would have more than 32 * bits, returns the low 32 bits of the result. * * @since 14.0 */ @GwtIncompatible // Does not truncate correctly public UnsignedInteger times(UnsignedInteger val) { // TODO(lowasser): make this GWT-compatible return fromIntBits(value * checkNotNull(val).value); }
@Beta @GwtIncompatible public final class PatternFilenameFilter implements FilenameFilter {
@GwtIncompatible // serialization @Override public void forEach(Consumer<? super V> action) { checkNotNull(action); map.forEach((k, v) -> action.accept(v)); }
@Beta @GwtIncompatible public final class CountingOutputStream extends FilterOutputStream {
@GwtIncompatible static Reader ignoringReader(final Reader delegate, final String toIgnore) { checkNotNull(delegate); checkNotNull(toIgnore); return new Reader() { @Override public int read() throws IOException { int readChar; do { readChar = delegate.read(); } while (readChar != -1 && toIgnore.indexOf((char) readChar) >= 0); return readChar; } @Override public int read(char[] cbuf, int off, int len) throws IOException { throw new UnsupportedOperationException(); } @Override public void close() throws IOException { delegate.close(); } }; }