}
private <T extends Component> Component deserializeOnto(Component targetComponent, EntityData.Component componentData,
ComponentMetadata<T> componentMetadata, FieldSerializeCheck<Component> fieldCheck) {
Serializer serializer = typeSerializationLibrary.getSerializerFor(componentMetadata);
DeserializationContext context = new ProtobufDeserializationContext(typeSerializationLibrary);
Map<FieldMetadata<?, ?>, PersistedData> dataMap = Maps.newHashMapWithExpectedSize(componentData.getFieldCount());
for (EntityData.NameValue field : componentData.getFieldList()) {
FieldMetadata<?, ?> fieldInfo = null;
if (field.hasNameIndex()) {
fieldInfo = componentMetadata.getField(field.getNameIndex());
} else if (field.hasName()) {
fieldInfo = componentMetadata.getField(field.getName());
}
if (fieldInfo != null) {
dataMap.put(fieldInfo, new ProtobufPersistedData(field.getValue()));
} else if (field.hasNameIndex()) {
logger.warn("Cannot deserialize unknown field '{}' onto '{}'", field.getName(), componentMetadata.getUri());
}
}
serializer.deserializeOnto(targetComponent, dataMap, context, fieldCheck);
return targetComponent;
}