Package com.oracle.coherence.grpc
Class BinaryHelper
- java.lang.Object
-
- com.oracle.coherence.grpc.BinaryHelper
-
-
Field Summary
Fields Modifier and Type Field Description static com.google.protobuf.Empty
EMPTY
SingletonEmpty
.static com.google.protobuf.ByteString
EMPTY_BYTE_STRING
Singleton emptyByteString
.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> T
fromBinary(Binary binary, Serializer serializer)
Deserialize a serializedBinary
.static <T> T
fromByteString(com.google.protobuf.ByteString bytes, Serializer serializer)
A utility method to deserialize aByteString
to an Object.static <T> T
fromBytesValue(com.google.protobuf.BytesValue bytes, Serializer serializer)
A utility method to deserialize aBytesValue
to an Object.static Binary
toBinary(com.google.protobuf.ByteString bytes)
Convert aByteString
to aBinary
.static Binary
toBinary(com.google.protobuf.BytesValue bytes)
Convert aBytesValue
to aBinary
.static com.google.protobuf.ByteString
toByteString(Binary binary)
Convert aBinary
to aByteString
.static com.google.protobuf.ByteString
toByteString(Object value, Serializer serializer)
Serialize the specified value to aByteString
.static com.google.protobuf.BytesValue
toBytesValue(Binary binary)
Convert aBinary
to aBytesValue
.static com.google.protobuf.BytesValue
toBytesValue(Object value, Serializer serializer)
Serialize the specified value to aBytesValue
.static com.oracle.coherence.grpc.Entry
toEntry(com.google.protobuf.ByteString key, com.google.protobuf.ByteString value)
Create anEntry
containing the specified key and value.static com.oracle.coherence.grpc.Entry
toEntry(Map.Entry<?,?> entry, Serializer serializer)
Create anEntry
from aMap.Entry
.static List<com.oracle.coherence.grpc.Entry>
toEntryList(Map<?,?> map, Serializer serializer)
Create aMap
to a list ofEntry
instances.static com.google.protobuf.ByteString
toKeyByteString(Binary bin, Object obj, Serializer serializer)
static ReadBuffer
toReadBuffer(com.google.protobuf.ByteString bytes)
Convert aByteString
to aReadBuffer
.static Stream<com.google.protobuf.StringValue>
toStringValueStream(Iterable<?> iterable)
-
-
-
Method Detail
-
toBinary
public static Binary toBinary(com.google.protobuf.BytesValue bytes)
Convert aBytesValue
to aBinary
.The
BytesValue
is converted to a list ofByteBuffer
s which are then converted toByteBufferReadBuffer
s and finally to aBinary
to avoid copying byte arrays.- Parameters:
bytes
- theBytesValue
to convert- Returns:
- a
Binary
containing the bytes of theBytesValue
- Throws:
NullPointerException
- if theBytesValue
isnull
-
toBinary
public static Binary toBinary(com.google.protobuf.ByteString bytes)
Convert aByteString
to aBinary
.The
ByteString
is converted to a list ofByteBuffer
s which are then converted toByteBufferReadBuffer
s and finally to aBinary
to avoid copying byte arrays.- Parameters:
bytes
- theByteString
to convert- Returns:
- a
Binary
containing the bytes of theByteString
- Throws:
NullPointerException
- if theByteString
isnull
-
toReadBuffer
public static ReadBuffer toReadBuffer(com.google.protobuf.ByteString bytes)
Convert aByteString
to aReadBuffer
.The
ByteString
is converted to a list ofByteBuffer
s which are then converted toByteBufferReadBuffer
s and finally to aBinary
to avoid copying byte arrays.- Parameters:
bytes
- theByteString
to convert- Returns:
- a
ReadBuffer
containing the bytes of theByteString
- Throws:
NullPointerException
- if theByteString
isnull
-
fromBinary
public static <T> T fromBinary(Binary binary, Serializer serializer)
Deserialize a serializedBinary
.- Type Parameters:
T
- the type of the original object theBinary
represents- Parameters:
binary
- theBinary
to deserializeserializer
- theSerializer
to use- Returns:
- the deserialized
Binary
value ornull
if theBinary
isnull
-
toBytesValue
public static com.google.protobuf.BytesValue toBytesValue(Binary binary)
-
toByteString
public static com.google.protobuf.ByteString toByteString(Binary binary)
-
fromBytesValue
public static <T> T fromBytesValue(com.google.protobuf.BytesValue bytes, Serializer serializer)
A utility method to deserialize aBytesValue
to an Object.- Type Parameters:
T
- the expected value type- Parameters:
bytes
- theBytesValue
to deserialize an Object.serializer
- theSerializer
to use to convert the binary stream to an object- Returns:
- an object from the specified
BytesValue
-
fromByteString
public static <T> T fromByteString(com.google.protobuf.ByteString bytes, Serializer serializer)
A utility method to deserialize aByteString
to an Object.- Type Parameters:
T
- the expected value type- Parameters:
bytes
- theByteString
to deserialize an Object.serializer
- theSerializer
to use to convert the binary stream to an object- Returns:
- an object from the specified
ByteString
-
toBytesValue
public static com.google.protobuf.BytesValue toBytesValue(Object value, Serializer serializer)
Serialize the specified value to aBytesValue
.- Parameters:
value
- the value to serializeserializer
- theSerializer
to use- Returns:
- the serialized value as a
BytesValue
-
toByteString
public static com.google.protobuf.ByteString toByteString(Object value, Serializer serializer)
Serialize the specified value to aByteString
.- Parameters:
value
- the value to serializeserializer
- theSerializer
to use- Returns:
- the serialized value as a
ByteString
-
toEntryList
public static List<com.oracle.coherence.grpc.Entry> toEntryList(Map<?,?> map, Serializer serializer)
Create aMap
to a list ofEntry
instances.- Parameters:
map
- theMap
to convert to a list ofEntry
instancesserializer
- theSerializer
to use- Returns:
- a list of
Entry
instances - Throws:
NullPointerException
- if the map isnull
-
toEntry
public static com.oracle.coherence.grpc.Entry toEntry(Map.Entry<?,?> entry, Serializer serializer)
Create anEntry
from aMap.Entry
.- Parameters:
entry
- theMap.Entry
to convert to anEntry
serializer
- theSerializer
to use- Returns:
- an
Entry
containing the specified key and value - Throws:
NullPointerException
- if the entry isnull
-
toEntry
public static com.oracle.coherence.grpc.Entry toEntry(com.google.protobuf.ByteString key, com.google.protobuf.ByteString value)
Create anEntry
containing the specified key and value.- Parameters:
key
- the entry's keyvalue
- the entry's value- Returns:
- an
Entry
containing the specified key and value
-
toStringValueStream
public static Stream<com.google.protobuf.StringValue> toStringValueStream(Iterable<?> iterable)
-
toKeyByteString
public static com.google.protobuf.ByteString toKeyByteString(Binary bin, Object obj, Serializer serializer)
-
-