Updated README.md, custom readers take precedence

This commit is contained in:
Christian Basler 2017-02-10 07:35:46 +01:00
parent 97dad0a7b9
commit 0c0bf3c324
2 changed files with 5 additions and 2 deletions

View File

@ -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
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.
* 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
-----

View File

@ -27,7 +27,7 @@ import java.util.List;
* Reads MPType object from an {@link InputStream}.
*/
public class Reader {
private List<MPType.Unpacker<?>> unpackers = new LinkedList<>();
private LinkedList<MPType.Unpacker<?>> unpackers = new LinkedList<>();
private static final Reader instance = new Reader();
@ -50,7 +50,7 @@ public class Reader {
* Register your own extensions
*/
public void register(MPType.Unpacker<?> unpacker) {
unpackers.add(unpacker);
unpackers.addFirst(unpacker);
}
public MPType read(InputStream in) throws IOException {