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.EmptyEMPTYSingletonEmpty.static com.google.protobuf.ByteStringEMPTY_BYTE_STRINGSingleton emptyByteString.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> TfromBinary(Binary binary, Serializer serializer)Deserialize a serializedBinary.static <T> TfromByteString(com.google.protobuf.ByteString bytes, Serializer serializer)A utility method to deserialize aByteStringto an Object.static <T> TfromBytesValue(com.google.protobuf.BytesValue bytes, Serializer serializer)A utility method to deserialize aBytesValueto an Object.static BinarytoBinary(com.google.protobuf.ByteString bytes)Convert aByteStringto aBinary.static BinarytoBinary(com.google.protobuf.BytesValue bytes)Convert aBytesValueto aBinary.static com.google.protobuf.ByteStringtoByteString(Binary binary)Convert aBinaryto aByteString.static com.google.protobuf.ByteStringtoByteString(Object value, Serializer serializer)Serialize the specified value to aByteString.static com.google.protobuf.BytesValuetoBytesValue(Binary binary)Convert aBinaryto aBytesValue.static com.google.protobuf.BytesValuetoBytesValue(Object value, Serializer serializer)Serialize the specified value to aBytesValue.static com.oracle.coherence.grpc.EntrytoEntry(com.google.protobuf.ByteString key, com.google.protobuf.ByteString value)Create anEntrycontaining the specified key and value.static com.oracle.coherence.grpc.EntrytoEntry(Map.Entry<?,?> entry, Serializer serializer)Create anEntryfrom aMap.Entry.static List<com.oracle.coherence.grpc.Entry>toEntryList(Map<?,?> map, Serializer serializer)Create aMapto a list ofEntryinstances.static com.google.protobuf.ByteStringtoKeyByteString(Binary bin, Object obj, Serializer serializer)static ReadBuffertoReadBuffer(com.google.protobuf.ByteString bytes)Convert aByteStringto aReadBuffer.static Stream<com.google.protobuf.StringValue>toStringValueStream(Iterable<?> iterable)
-
-
-
Method Detail
-
toBinary
public static Binary toBinary(com.google.protobuf.BytesValue bytes)
Convert aBytesValueto aBinary.The
BytesValueis converted to a list ofByteBuffers which are then converted toByteBufferReadBuffers and finally to aBinaryto avoid copying byte arrays.- Parameters:
bytes- theBytesValueto convert- Returns:
- a
Binarycontaining the bytes of theBytesValue - Throws:
NullPointerException- if theBytesValueisnull
-
toBinary
public static Binary toBinary(com.google.protobuf.ByteString bytes)
Convert aByteStringto aBinary.The
ByteStringis converted to a list ofByteBuffers which are then converted toByteBufferReadBuffers and finally to aBinaryto avoid copying byte arrays.- Parameters:
bytes- theByteStringto convert- Returns:
- a
Binarycontaining the bytes of theByteString - Throws:
NullPointerException- if theByteStringisnull
-
toReadBuffer
public static ReadBuffer toReadBuffer(com.google.protobuf.ByteString bytes)
Convert aByteStringto aReadBuffer.The
ByteStringis converted to a list ofByteBuffers which are then converted toByteBufferReadBuffers and finally to aBinaryto avoid copying byte arrays.- Parameters:
bytes- theByteStringto convert- Returns:
- a
ReadBuffercontaining the bytes of theByteString - Throws:
NullPointerException- if theByteStringisnull
-
fromBinary
public static <T> T fromBinary(Binary binary, Serializer serializer)
Deserialize a serializedBinary.- Type Parameters:
T- the type of the original object theBinaryrepresents- Parameters:
binary- theBinaryto deserializeserializer- theSerializerto use- Returns:
- the deserialized
Binaryvalue ornullif theBinaryisnull
-
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 aBytesValueto an Object.- Type Parameters:
T- the expected value type- Parameters:
bytes- theBytesValueto deserialize an Object.serializer- theSerializerto 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 aByteStringto an Object.- Type Parameters:
T- the expected value type- Parameters:
bytes- theByteStringto deserialize an Object.serializer- theSerializerto 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- theSerializerto 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- theSerializerto use- Returns:
- the serialized value as a
ByteString
-
toEntryList
public static List<com.oracle.coherence.grpc.Entry> toEntryList(Map<?,?> map, Serializer serializer)
Create aMapto a list ofEntryinstances.- Parameters:
map- theMapto convert to a list ofEntryinstancesserializer- theSerializerto use- Returns:
- a list of
Entryinstances - Throws:
NullPointerException- if the map isnull
-
toEntry
public static com.oracle.coherence.grpc.Entry toEntry(Map.Entry<?,?> entry, Serializer serializer)
Create anEntryfrom aMap.Entry.- Parameters:
entry- theMap.Entryto convert to anEntryserializer- theSerializerto use- Returns:
- an
Entrycontaining 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 anEntrycontaining the specified key and value.- Parameters:
key- the entry's keyvalue- the entry's value- Returns:
- an
Entrycontaining 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)
-
-