Class Funnels


  • @Beta
    public final class Funnels
    extends Object
    Funnels for common types. All implementations are serializable.
    Since:
    11.0
    Author:
    Dimitris Andreou
    • Method Detail

      • byteArrayFunnel

        public static Funnel<byte[]> byteArrayFunnel()
        Returns a funnel that extracts the bytes from a byte array.
      • unencodedCharsFunnel

        public static Funnel<CharSequenceunencodedCharsFunnel()
        Returns a funnel that extracts the characters from a CharSequence, a character at a time, without performing any encoding. If you need to use a specific encoding, use stringFunnel(Charset) instead.
        Since:
        15.0 (since 11.0 as Funnels.stringFunnel().
      • stringFunnel

        public static Funnel<CharSequencestringFunnel​(Charset charset)
        Returns a funnel that encodes the characters of a CharSequence with the specified Charset.
        Since:
        15.0
      • sequentialFunnel

        public static <E extends @Nullable ObjectFunnel<Iterable<? extends E>> sequentialFunnel​(Funnel<E> elementFunnel)
        Returns a funnel that processes an Iterable by funneling its elements in iteration order with the specified funnel. No separators are added between the elements.
        Since:
        15.0
      • asOutputStream

        public static OutputStream asOutputStream​(PrimitiveSink sink)
        Wraps a PrimitiveSink as an OutputStream, so it is easy to funnel an object to a PrimitiveSink if there is already a way to write the contents of the object to an OutputStream.

        The close and flush methods of the returned OutputStream do nothing, and no method throws IOException.

        Since:
        13.0