Clarifications for SerializableData

This commit is contained in:
themode 2020-10-02 04:26:10 +02:00
parent a7163c8d1c
commit 0f71b4c9d4
2 changed files with 8 additions and 3 deletions

View File

@ -41,6 +41,8 @@ public interface SerializableData extends Data {
/**
* Read the data of a {@link SerializableData} when you already have the index map
* <p>
* WARNING: the data to read should not have any index to read and your index map should be COMPLETE
*
* @param reader the binary reader
* @param typeToIndexMap the index map
@ -56,7 +58,7 @@ public interface SerializableData extends Data {
void readIndexedSerializedData(BinaryReader reader);
/**
* Get the index info (class name -&gt; class index)
* Write the index info (class name -&gt; class index), used to write the header for indexed serialized data
* <p>
* Sized by a var-int
*
@ -78,7 +80,9 @@ public interface SerializableData extends Data {
}
/**
* Get a map containing the indexes of your data (type name -&gt; type index)
* Read a data index map (type name -&gt; type index)
* <p>
* Can then be used with {@link SerializableData#readSerializedData(BinaryReader, Object2ShortMap)}
*
* @param binaryReader the reader
* @return a map containing the indexes of your data

View File

@ -145,10 +145,11 @@ public class SerializableDataImpl extends DataImpl implements SerializableData {
* WARNING: the {@link DataManager} needs to have all the required types as the {@link SerializableData} has
*
* @param data the object to append the data
* @param typeToIndexMap the map which index all the type contained in the data (className-&gt;classIndex)
* @param typeToIndexMap the map which index all the types contained in the data (className-&gt;classIndex)
* @param reader the reader
*/
private static void readIndexedData(SerializableData data, Object2ShortMap<String> typeToIndexMap, BinaryReader reader) {
// Map used to convert an index to the class name (opposite of typeToIndexMap)
final Short2ObjectMap<String> indexToTypeMap = new Short2ObjectOpenHashMap<>(typeToIndexMap.size());
{
// Fill the indexToType map