mirror of
https://github.com/msgpack/msgpack-python.git
synced 2026-02-06 17:59:52 +00:00
java: supports Collection<T> to pack
This commit is contained in:
parent
65515638aa
commit
4067c56b5d
2 changed files with 11 additions and 0 deletions
|
|
@ -23,6 +23,7 @@ import java.nio.ByteBuffer;
|
|||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.Map;
|
||||
import java.util.Collection;
|
||||
import java.math.BigInteger;
|
||||
|
||||
import org.msgpack.annotation.MessagePackDelegate;
|
||||
|
|
@ -480,6 +481,11 @@ public class Packer {
|
|||
pack(e.getValue());
|
||||
}
|
||||
return this;
|
||||
} else if(o instanceof Collection) {
|
||||
Collection<Object> l = (Collection<Object>)o;
|
||||
packArray(l.size());
|
||||
for(Object i : l) { pack(i); }
|
||||
return this;
|
||||
//} else if(o instanceof Boolean) {
|
||||
// if((Boolean)o) {
|
||||
// return packTrue();
|
||||
|
|
|
|||
|
|
@ -30,6 +30,10 @@ public class Templates {
|
|||
return new MapTemplate(keyTemplate, valueTemplate);
|
||||
}
|
||||
|
||||
public static Template tCollection(Template elementTemplate) {
|
||||
return new CollectionTemplate(elementTemplate);
|
||||
}
|
||||
|
||||
public static Template tClass(Class target) {
|
||||
return new ClassTemplate(target);
|
||||
}
|
||||
|
|
@ -84,5 +88,6 @@ public class Templates {
|
|||
public static Template tByteArray() {
|
||||
return TByteArray;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue