Updated README.md, custom readers take precedence
This commit is contained in:
parent
97dad0a7b9
commit
0c0bf3c324
@ -32,6 +32,9 @@ Limitations
|
|||||||
* `MPFloat` uses the data type you're using to decide on precision (float 32 or 64) - not the actual value. E.g. 0.5
|
* `MPFloat` uses the data type you're using to decide on precision (float 32 or 64) - not the actual value. E.g. 0.5
|
||||||
could be saved perfectly as a float 42, but if you provide a double value, it will be stored as float 64, wasting
|
could be saved perfectly as a float 42, but if you provide a double value, it will be stored as float 64, wasting
|
||||||
4 bytes.
|
4 bytes.
|
||||||
|
* If you want to use the 'ext format family', you'll need to implement and register your own `MPType` and
|
||||||
|
`MPType.Unpacker`. Be aware that they take precedence over the default unpackers, meaning if you accidentally define
|
||||||
|
your unpacker to handle strings, for example, you won't be able to unpack any regular strings anymore.
|
||||||
|
|
||||||
Setup
|
Setup
|
||||||
-----
|
-----
|
||||||
|
@ -27,7 +27,7 @@ import java.util.List;
|
|||||||
* Reads MPType object from an {@link InputStream}.
|
* Reads MPType object from an {@link InputStream}.
|
||||||
*/
|
*/
|
||||||
public class Reader {
|
public class Reader {
|
||||||
private List<MPType.Unpacker<?>> unpackers = new LinkedList<>();
|
private LinkedList<MPType.Unpacker<?>> unpackers = new LinkedList<>();
|
||||||
|
|
||||||
private static final Reader instance = new Reader();
|
private static final Reader instance = new Reader();
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ public class Reader {
|
|||||||
* Register your own extensions
|
* Register your own extensions
|
||||||
*/
|
*/
|
||||||
public void register(MPType.Unpacker<?> unpacker) {
|
public void register(MPType.Unpacker<?> unpacker) {
|
||||||
unpackers.add(unpacker);
|
unpackers.addFirst(unpacker);
|
||||||
}
|
}
|
||||||
|
|
||||||
public MPType read(InputStream in) throws IOException {
|
public MPType read(InputStream in) throws IOException {
|
||||||
|
Loading…
Reference in New Issue
Block a user