mirror of
https://github.com/msgpack/msgpack-c
synced 2026-06-08 16:11:40 +00:00
java: adds NullableTemplate 2
This commit is contained in:
@@ -23,19 +23,16 @@ public class Templates {
|
||||
public static void load() { }
|
||||
|
||||
|
||||
public static Template tNullable(Template elementTemplate) {
|
||||
return new NullableTemplate(elementTemplate);
|
||||
}
|
||||
|
||||
|
||||
public static final Template TAny = AnyTemplate.getInstance();
|
||||
public static Template tAny() {
|
||||
return TAny;
|
||||
}
|
||||
|
||||
public static Template tOptional(Template elementTemplate) {
|
||||
return new OptionalTemplate(elementTemplate);
|
||||
}
|
||||
|
||||
public static Template tOptional(Template elementTemplate, Object defaultObject) {
|
||||
return new OptionalTemplate(elementTemplate, defaultObject);
|
||||
}
|
||||
|
||||
|
||||
public static Template tList(Template elementTemplate) {
|
||||
return new ListTemplate(elementTemplate);
|
||||
|
||||
@@ -23,6 +23,8 @@ import java.io.IOException;
|
||||
import java.util.Iterator;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.math.BigInteger;
|
||||
import org.msgpack.template.ClassTemplate;
|
||||
import org.msgpack.template.NullableTemplate;
|
||||
|
||||
/**
|
||||
* Unpacker enables you to deserialize objects from stream.
|
||||
@@ -581,8 +583,8 @@ public class Unpacker implements Iterable<MessagePackObject> {
|
||||
}
|
||||
|
||||
final public <T> T unpack(Class<T> klass) throws IOException, MessageTypeException {
|
||||
// FIXME optional?
|
||||
return (T)unpack(Templates.tOptional(Templates.tClass(klass)));
|
||||
// FIXME nullable?
|
||||
return (T)unpack(new NullableTemplate(new ClassTemplate(klass)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user