mirror of
https://github.com/msgpack/msgpack-c.git
synced 2025-10-25 10:09:38 +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.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Collection;
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
|
|
||||||
import org.msgpack.annotation.MessagePackDelegate;
|
import org.msgpack.annotation.MessagePackDelegate;
|
||||||
@@ -480,6 +481,11 @@ public class Packer {
|
|||||||
pack(e.getValue());
|
pack(e.getValue());
|
||||||
}
|
}
|
||||||
return this;
|
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) {
|
//} else if(o instanceof Boolean) {
|
||||||
// if((Boolean)o) {
|
// if((Boolean)o) {
|
||||||
// return packTrue();
|
// return packTrue();
|
||||||
|
|||||||
@@ -30,6 +30,10 @@ public class Templates {
|
|||||||
return new MapTemplate(keyTemplate, valueTemplate);
|
return new MapTemplate(keyTemplate, valueTemplate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Template tCollection(Template elementTemplate) {
|
||||||
|
return new CollectionTemplate(elementTemplate);
|
||||||
|
}
|
||||||
|
|
||||||
public static Template tClass(Class target) {
|
public static Template tClass(Class target) {
|
||||||
return new ClassTemplate(target);
|
return new ClassTemplate(target);
|
||||||
}
|
}
|
||||||
@@ -84,5 +88,6 @@ public class Templates {
|
|||||||
public static Template tByteArray() {
|
public static Template tByteArray() {
|
||||||
return TByteArray;
|
return TByteArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user