mirror of
https://github.com/msgpack/msgpack-c
synced 2026-06-08 16:11:40 +00:00
java: fixes ListTemplate and MapTemplate
This commit is contained in:
@@ -34,10 +34,11 @@ public class ListTemplate implements Template {
|
||||
}
|
||||
|
||||
public void pack(Packer pk, Object target) throws IOException {
|
||||
if(target instanceof List) {
|
||||
if(!(target instanceof List)) {
|
||||
throw new MessageTypeException();
|
||||
}
|
||||
List<Object> list = (List<Object>)target;
|
||||
pk.packArray(list.size());
|
||||
for(Object element : list) {
|
||||
elementTemplate.pack(pk, element);
|
||||
}
|
||||
|
||||
@@ -40,10 +40,11 @@ public class MapTemplate implements Template {
|
||||
}
|
||||
|
||||
public void pack(Packer pk, Object target) throws IOException {
|
||||
if(target instanceof Map) {
|
||||
if(!(target instanceof Map)) {
|
||||
throw new MessageTypeException();
|
||||
}
|
||||
Map<Object,Object> map = (Map<Object,Object>)target;
|
||||
pk.packMap(map.size());
|
||||
for(Map.Entry<Object,Object> pair : map.entrySet()) {
|
||||
keyTemplate.pack(pk, pair.getKey());
|
||||
valueTemplate.pack(pk, pair.getValue());
|
||||
|
||||
Reference in New Issue
Block a user