mirror of
https://github.com/msgpack/msgpack-c.git
synced 2025-03-27 00:35:18 +01:00
java: NilType::create() returns NilType's one and only instance
This commit is contained in:
parent
193a739749
commit
1d17836b7d
@ -23,7 +23,7 @@ import java.util.Map;
|
||||
import java.math.BigInteger;
|
||||
|
||||
public abstract class MessagePackObject implements Cloneable, MessagePackable {
|
||||
public boolean isNull() {
|
||||
public boolean isNil() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -21,14 +21,16 @@ import java.io.IOException;
|
||||
import org.msgpack.*;
|
||||
|
||||
public class NilType extends MessagePackObject {
|
||||
private static NilType instance = new NilType();
|
||||
private final static NilType INSTANCE = new NilType();
|
||||
|
||||
public static NilType create() {
|
||||
return instance;
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
private NilType() { }
|
||||
|
||||
@Override
|
||||
public boolean isNull() {
|
||||
public boolean isNil() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -52,7 +54,7 @@ public class NilType extends MessagePackObject {
|
||||
|
||||
@Override
|
||||
public Object clone() {
|
||||
return new NilType();
|
||||
return INSTANCE;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -130,7 +130,7 @@ public class TestPackUnpack {
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
new Packer(out).packNil();
|
||||
MessagePackObject obj = unpackOne(out);
|
||||
assertTrue(obj.isNull());
|
||||
assertTrue(obj.isNil());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Loading…
x
Reference in New Issue
Block a user