Package com.exonum.binding.common.hash
Class Funnels
- java.lang.Object
-
- com.exonum.binding.common.hash.Funnels
-
public final class Funnels extends Object
Funnels for common types. All implementations are serializable.- Since:
- 11.0
- Author:
- Dimitris Andreou
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classFunnels.HashCodeFunnelHashCode funnel.
-
Method Summary
Modifier and Type Method Description static OutputStreamasOutputStream(PrimitiveSink sink)Wraps aPrimitiveSinkas anOutputStream, so it is easy tofunnelan object to aPrimitiveSinkif there is already a way to write the contents of the object to anOutputStream.static Funnel<byte[]>byteArrayFunnel()Returns a funnel that extracts the bytes from abytearray.static Funnel<HashCode>hashCodeFunnel()Returns a funnel for hashcode.static Funnel<Integer>integerFunnel()Returns a funnel for integers.static Funnel<Long>longFunnel()Returns a funnel for longs.static <E> Funnel<Iterable<? extends E>>sequentialFunnel(Funnel<E> elementFunnel)Returns a funnel that processes anIterableby funneling its elements in iteration order with the specified funnel.static Funnel<CharSequence>stringFunnel(Charset charset)Returns a funnel that encodes the characters of aCharSequencewith the specifiedCharset.static Funnel<CharSequence>unencodedCharsFunnel()Returns a funnel that extracts the characters from aCharSequence, a character at a time, without performing any encoding.
-
-
-
Method Detail
-
byteArrayFunnel
public static Funnel<byte[]> byteArrayFunnel()
Returns a funnel that extracts the bytes from abytearray.
-
unencodedCharsFunnel
public static Funnel<CharSequence> unencodedCharsFunnel()
Returns a funnel that extracts the characters from aCharSequence, a character at a time, without performing any encoding. If you need to use a specific encoding, usestringFunnel(Charset)instead.- Since:
- 15.0 (since 11.0 as
Funnels.stringFunnel().
-
stringFunnel
public static Funnel<CharSequence> stringFunnel(Charset charset)
Returns a funnel that encodes the characters of aCharSequencewith the specifiedCharset.- Since:
- 15.0
-
integerFunnel
public static Funnel<Integer> integerFunnel()
Returns a funnel for integers.- Since:
- 13.0
-
sequentialFunnel
public static <E> Funnel<Iterable<? extends E>> sequentialFunnel(Funnel<E> elementFunnel)
Returns a funnel that processes anIterableby 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 aPrimitiveSinkas anOutputStream, so it is easy tofunnelan object to aPrimitiveSinkif there is already a way to write the contents of the object to anOutputStream.The
closeandflushmethods of the returnedOutputStreamdo nothing, and no method throwsIOException.- Since:
- 13.0
-
-