public Map<MetadataType, MetadataComponent> deserialize(Descriptor descriptor, FileDataInput in, EnumSet<MetadataType> types) throws IOException { Map<MetadataType, MetadataComponent> components = new EnumMap<>(MetadataType.class); // read number of components int numComponents = in.readInt(); // read toc Map<MetadataType, Integer> toc = new EnumMap<>(MetadataType.class); MetadataType[] values = MetadataType.values(); for (int i = 0; i < numComponents; i++) { toc.put(values[in.readInt()], in.readInt()); } for (MetadataType type : types) { Integer offset = toc.get(type); if (offset != null) { in.seek(offset); MetadataComponent component = type.serializer.deserialize(descriptor.version, in); components.put(type, component); } } return components; }
public Map<MetadataType, MetadataComponent> deserialize(Descriptor descriptor, FileDataInput in, EnumSet<MetadataType> types) throws IOException { Map<MetadataType, MetadataComponent> components = new EnumMap<>(MetadataType.class); // read number of components int numComponents = in.readInt(); // read toc Map<MetadataType, Integer> toc = new EnumMap<>(MetadataType.class); MetadataType[] values = MetadataType.values(); for (int i = 0; i < numComponents; i++) { toc.put(values[in.readInt()], in.readInt()); } for (MetadataType type : types) { Integer offset = toc.get(type); if (offset != null) { in.seek(offset); MetadataComponent component = type.serializer.deserialize(descriptor.version, in); components.put(type, component); } } return components; }
public Map<MetadataType, MetadataComponent> deserialize(Descriptor descriptor, FileDataInput in, EnumSet<MetadataType> types) throws IOException { Map<MetadataType, MetadataComponent> components = new EnumMap<>(MetadataType.class); // read number of components int numComponents = in.readInt(); // read toc Map<MetadataType, Integer> toc = new EnumMap<>(MetadataType.class); MetadataType[] values = MetadataType.values(); for (int i = 0; i < numComponents; i++) { toc.put(values[in.readInt()], in.readInt()); } for (MetadataType type : types) { Integer offset = toc.get(type); if (offset != null) { in.seek(offset); MetadataComponent component = type.serializer.deserialize(descriptor.version, in); components.put(type, component); } } return components; }
public Map<MetadataType, MetadataComponent> deserialize(Descriptor descriptor, FileDataInput in, EnumSet<MetadataType> types) throws IOException { Map<MetadataType, MetadataComponent> components = new EnumMap<>(MetadataType.class); // read number of components int numComponents = in.readInt(); // read toc Map<MetadataType, Integer> toc = new EnumMap<>(MetadataType.class); MetadataType[] values = MetadataType.values(); for (int i = 0; i < numComponents; i++) { toc.put(values[in.readInt()], in.readInt()); } for (MetadataType type : types) { Integer offset = toc.get(type); if (offset != null) { in.seek(offset); MetadataComponent component = type.serializer.deserialize(descriptor.version, in); components.put(type, component); } } return components; }
public Map<MetadataType, MetadataComponent> deserialize(Descriptor descriptor, FileDataInput in, EnumSet<MetadataType> types) throws IOException { Map<MetadataType, MetadataComponent> components = Maps.newHashMap(); // read number of components int numComponents = in.readInt(); // read toc Map<MetadataType, Integer> toc = new HashMap<>(numComponents); for (int i = 0; i < numComponents; i++) { toc.put(MetadataType.values()[in.readInt()], in.readInt()); } for (MetadataType type : types) { MetadataComponent component = null; if (toc.containsKey(type)) { in.seek(toc.get(type)); component = type.serializer.deserialize(descriptor.version, in); } components.put(type, component); } return components; }