MCPcopy Create free account
hub / github.com/bft-smart/library / fromBytes

Method fromBytes

src/main/java/bftsmart/demo/map/MapMessage.java:54–83  ·  view source on GitHub ↗
(byte[] rep)

Source from the content-addressed store, hash-verified

52 }
53
54 @SuppressWarnings("unchecked")
55 public static <K,V> MapMessage<K,V> fromBytes(byte[] rep) throws IOException, ClassNotFoundException {
56 ByteArrayInputStream byteIn = new ByteArrayInputStream(rep);
57 ObjectInputStream objIn = new ObjectInputStream(byteIn);
58 MapMessage<K,V> msg = new MapMessage<>();
59 boolean hasType = objIn.readBoolean();
60 if(hasType) {
61 msg.setType((MapRequestType) objIn.readObject());
62 }
63 boolean hasKey = objIn.readBoolean();
64 if(hasKey) {
65 msg.setKey(objIn.readObject());
66 }
67 boolean hasValue = objIn.readBoolean();
68 if(hasValue) {
69 msg.setValue(objIn.readObject());
70 }
71 msg.setSize(objIn.readInt());
72 boolean hasKeySet = objIn.readBoolean();
73 if(hasKeySet) {
74 int setSize = objIn.readInt();
75 Set<K> result = new HashSet<>();
76 while (setSize-- > 0) {
77 result.add((K)objIn.readObject());
78 }
79 msg.setKeySet(result);
80 }
81
82 return msg;
83 }
84
85 public MapRequestType getType() {
86 return type;

Callers 7

appExecuteOrderedMethod · 0.95
appExecuteUnorderedMethod · 0.95
putMethod · 0.95
getMethod · 0.95
removeMethod · 0.95
sizeMethod · 0.95
keySetMethod · 0.95

Calls 6

setTypeMethod · 0.95
setKeyMethod · 0.95
setValueMethod · 0.95
setSizeMethod · 0.95
setKeySetMethod · 0.95
addMethod · 0.80

Tested by

no test coverage detected