2019-05-15 01:25:46 +03:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
import { Coder, Reader, Writer } from "./abstract-coder";
|
|
|
|
|
|
|
|
export class NullCoder extends Coder {
|
|
|
|
|
|
|
|
constructor(localName: string) {
|
|
|
|
super("null", "", localName, false);
|
|
|
|
}
|
|
|
|
|
2020-11-23 08:59:44 +03:00
|
|
|
defaultValue(): null {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2019-05-15 01:25:46 +03:00
|
|
|
encode(writer: Writer, value: any): number {
|
|
|
|
if (value != null) { this._throwError("not null", value); }
|
|
|
|
return writer.writeBytes([ ]);
|
|
|
|
}
|
|
|
|
|
|
|
|
decode(reader: Reader): any {
|
|
|
|
reader.readBytes(0);
|
|
|
|
return reader.coerce(this.name, null);
|
|
|
|
}
|
|
|
|
}
|