mirror of
https://github.com/msgpack/msgpack-python.git
synced 2026-02-06 17:59:52 +00:00
java: NilType::create() returns NilType's one and only instance
This commit is contained in:
parent
193a739749
commit
1d17836b7d
3 changed files with 8 additions and 6 deletions
|
|
@ -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…
Add table
Add a link
Reference in a new issue