mirror of
https://github.com/msgpack/msgpack-c.git
synced 2025-10-24 09:12:30 +02:00
java: supports Collection<T> to pack
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user