From bcc5fca6a58b3c2b93ae2801ca2ea04d444af9a2 Mon Sep 17 00:00:00 2001 From: shawnhatch <30730734+shawnhatch@users.noreply.github.com> Date: Thu, 23 Mar 2023 15:55:07 -0400 Subject: [PATCH] State recording (#66) * Fixing issues where data managers are throwing contract exceptions while performing precondition checks interleaved with mutations to their data structures. * Fixing issues where data managers are throwing contract exceptions while performing precondition checks interleaved with mutations to their data structures. --------- Co-authored-by: Shawn --- .../datamangers/MaterialsDataManager.java | 236 +++++++++--------- .../PersonPropertiesDataManager.java | 83 +++--- .../datamanagers/RegionsDataManager.java | 21 +- 3 files changed, 161 insertions(+), 179 deletions(-) diff --git a/gcm4/src/main/java/plugins/materials/datamangers/MaterialsDataManager.java b/gcm4/src/main/java/plugins/materials/datamangers/MaterialsDataManager.java index b028cbf11..20c37c85f 100644 --- a/gcm4/src/main/java/plugins/materials/datamangers/MaterialsDataManager.java +++ b/gcm4/src/main/java/plugins/materials/datamangers/MaterialsDataManager.java @@ -632,12 +632,17 @@ private void handleMaterialsProducerPropertyDefinitionMutationEvent(DataManagerC validateMaterialsProducerPropertyIdIsUnknown(materialsProducerPropertyId); boolean checkAllProducersHaveValues = propertyDefinition.getDefaultValue().isEmpty(); - materialsProducerPropertyDefinitions.put(materialsProducerPropertyId, propertyDefinition); - materialsProducerPropertyCreationTimes.put(materialsProducerPropertyId, dataManagerContext.getTime()); - materialsProducerPropertyIds.add(materialsProducerPropertyId); + // validate the producer property value assignments + for (Pair pair : materialsProducerPropertyDefinitionInitialization.getPropertyValues()) { + MaterialsProducerId materialsProducerId = pair.getFirst(); + validateMaterialsProducerId(materialsProducerId); + } + /* + * If the property definition does not have a default value then we need + * to have a property assignment for each producer + */ if (checkAllProducersHaveValues) { - addNonDefaultProducerProperty(materialsProducerPropertyId); final Map coverageSet = new LinkedHashMap<>(); for (final MaterialsProducerId materialsProducerId : materialsProducerMap.keySet()) { @@ -647,35 +652,33 @@ private void handleMaterialsProducerPropertyDefinitionMutationEvent(DataManagerC for (Pair pair : materialsProducerPropertyDefinitionInitialization.getPropertyValues()) { MaterialsProducerId materialsProducerId = pair.getFirst(); coverageSet.put(materialsProducerId, true); - /* - * we do not have to validate the value since it is guaranteed - * to be consistent with the property definition by contract. - */ - Object value = pair.getSecond(); - Map propertyMap = materialsProducerPropertyMap.get(materialsProducerId); - PropertyValueRecord propertyValueRecord = new PropertyValueRecord(dataManagerContext); - propertyValueRecord.setPropertyValue(value); - propertyMap.put(materialsProducerPropertyId, propertyValueRecord); } for (MaterialsProducerId materialsProducerId : coverageSet.keySet()) { if (!coverageSet.get(materialsProducerId)) { throw new ContractException(PropertyError.INSUFFICIENT_PROPERTY_VALUE_ASSIGNMENT); } } - } else { - for (Pair pair : materialsProducerPropertyDefinitionInitialization.getPropertyValues()) { - MaterialsProducerId materialsProducerId = pair.getFirst(); - /* - * we do not have to validate the value since it is guaranteed - * to be consistent with the property definition by contract. - */ - Object value = pair.getSecond(); - Map propertyMap = materialsProducerPropertyMap.get(materialsProducerId); - PropertyValueRecord propertyValueRecord = new PropertyValueRecord(dataManagerContext); - propertyValueRecord.setPropertyValue(value); - propertyMap.put(materialsProducerPropertyId, propertyValueRecord); - } + } + + materialsProducerPropertyDefinitions.put(materialsProducerPropertyId, propertyDefinition); + materialsProducerPropertyCreationTimes.put(materialsProducerPropertyId, dataManagerContext.getTime()); + materialsProducerPropertyIds.add(materialsProducerPropertyId); + + if (checkAllProducersHaveValues) { + addNonDefaultProducerProperty(materialsProducerPropertyId); + } + for (Pair pair : materialsProducerPropertyDefinitionInitialization.getPropertyValues()) { + MaterialsProducerId materialsProducerId = pair.getFirst(); + /* + * we do not have to validate the value since it is guaranteed to be + * consistent with the property definition by contract. + */ + Object value = pair.getSecond(); + Map propertyMap = materialsProducerPropertyMap.get(materialsProducerId); + PropertyValueRecord propertyValueRecord = new PropertyValueRecord(dataManagerContext); + propertyValueRecord.setPropertyValue(value); + propertyMap.put(materialsProducerPropertyId, propertyValueRecord); } if (dataManagerContext.subscribersExist(MaterialsProducerPropertyDefinitionEvent.class)) { @@ -721,29 +724,31 @@ private void handleBatchPropertyDefinitionMutationEvent(DataManagerContext dataM batchPropertyDefinitions.get(materialId).put(batchPropertyId, propertyDefinition); batchPropertyDefinitionTimes.get(materialId).put(batchPropertyId, dataManagerContext.getTime()); + // validate the value assignments + for (Pair pair : batchPropertyDefinitionInitialization.getPropertyValues()) { + /* + * We know that the batch id and value are non-null and that the + * value is compatible with the property definition + */ + BatchId batchId = pair.getFirst(); + validateBatchId(batchId); + MaterialId batchMaterialId = batchRecords.get(batchId).materialId; + if (!materialId.equals(batchMaterialId)) { + throw new ContractException(MaterialsError.MATERIAL_TYPE_MISMATCH); + } + } + boolean checkAllBatchesHaveValues = propertyDefinition.getDefaultValue().isEmpty(); + /* + * if the property definition does not have a default value then every + * batch will need a property value assignment + */ if (checkAllBatchesHaveValues) { - addNonDefaultBatchProperty(materialId, batchPropertyId); BitSet coverageSet = new BitSet(batchRecords.size()); for (Pair pair : batchPropertyDefinitionInitialization.getPropertyValues()) { - /* - * We know that the batch id and value are non-null and that the - * value is compatible with the property definition - */ BatchId batchId = pair.getFirst(); - validateBatchId(batchId); - MaterialId batchMaterialId = batchRecords.get(batchId).materialId; - if (!materialId.equals(batchMaterialId)) { - throw new ContractException(MaterialsError.MATERIAL_TYPE_MISMATCH); - } - Object value = pair.getSecond(); - validateBatchId(batchId); - Map map = batchPropertyMap.get(batchId); - PropertyValueRecord propertyValueRecord = new PropertyValueRecord(dataManagerContext); - propertyValueRecord.setPropertyValue(value); - map.put(batchPropertyId, propertyValueRecord); coverageSet.set(batchId.getValue()); } @@ -755,29 +760,20 @@ private void handleBatchPropertyDefinitionMutationEvent(DataManagerContext dataM } } } + } - } else { - - for (Pair pair : batchPropertyDefinitionInitialization.getPropertyValues()) { - /* - * We know that the batch id and value are non-null and that the - * value is compatible with the property definition - */ - BatchId batchId = pair.getFirst(); - validateBatchId(batchId); - MaterialId batchMaterialId = batchRecords.get(batchId).materialId; - if (!materialId.equals(batchMaterialId)) { - throw new ContractException(MaterialsError.MATERIAL_TYPE_MISMATCH); - } - Object value = pair.getSecond(); - validateBatchId(batchId); - Map map = batchPropertyMap.get(batchId); - PropertyValueRecord propertyValueRecord = new PropertyValueRecord(dataManagerContext); - propertyValueRecord.setPropertyValue(value); - map.put(batchPropertyId, propertyValueRecord); - - } - + // if the property definition does not define a default value + if (checkAllBatchesHaveValues) { + addNonDefaultBatchProperty(materialId, batchPropertyId); + } + // integrate the batch property value assignments + for (Pair pair : batchPropertyDefinitionInitialization.getPropertyValues()) { + BatchId batchId = pair.getFirst(); + Object value = pair.getSecond(); + Map map = batchPropertyMap.get(batchId); + PropertyValueRecord propertyValueRecord = new PropertyValueRecord(dataManagerContext); + propertyValueRecord.setPropertyValue(value); + map.put(batchPropertyId, propertyValueRecord); } if (dataManagerContext.subscribersExist(BatchPropertyDefinitionEvent.class)) { @@ -1136,9 +1132,32 @@ public void addMaterialsProducer(MaterialsProducerConstructionData materialsProd private void handleMaterialsProducerAdditionMutationEvent(DataManagerContext dataManagerContext, MaterialsProducerAdditionMutationEvent materialsProducerAdditionMutationEvent) { MaterialsProducerConstructionData materialsProducerConstructionData = materialsProducerAdditionMutationEvent.materialsProducerConstructionData(); + // validate the new producer id MaterialsProducerId materialsProducerId = materialsProducerConstructionData.getMaterialsProducerId(); validateNewMaterialsProducerId(materialsProducerId); + // validate the included property value assignments + Map materialsProducerPropertyValues = materialsProducerConstructionData.getMaterialsProducerPropertyValues(); + for (MaterialsProducerPropertyId materialsProducerPropertyId : materialsProducerPropertyValues.keySet()) { + validateMaterialsProducerPropertyId(materialsProducerPropertyId); + Object propertyValue = materialsProducerPropertyValues.get(materialsProducerPropertyId); + final PropertyDefinition propertyDefinition = materialsProducerPropertyDefinitions.get(materialsProducerPropertyId); + validateValueCompatibility(materialsProducerPropertyId, propertyDefinition, propertyValue); + } + + /* + * if any of the property definitions don't have a default value, then + * the event must include those assignments + */ + boolean checkPropertyCoverage = !nonDefaultBearingProducerPropertyIds.isEmpty(); + if (checkPropertyCoverage) { + clearNonDefaultProducerChecks(); + for (MaterialsProducerPropertyId materialsProducerPropertyId : materialsProducerPropertyValues.keySet()) { + markProducerPropertyAssigned(materialsProducerPropertyId); + } + verifyNonDefaultChecksForProducers(); + } + // integrate the new producer into the resources final MaterialsProducerRecord materialsProducerRecord = new MaterialsProducerRecord(); materialsProducerRecord.materialProducerId = materialsProducerId; @@ -1148,36 +1167,14 @@ private void handleMaterialsProducerAdditionMutationEvent(DataManagerContext dat materialsProducerMap.put(materialsProducerId, materialsProducerRecord); // integrate the new producer into the property values - - boolean checkPropertyCoverage = !nonDefaultBearingProducerPropertyIds.isEmpty(); - Map materialsProducerPropertyValues = materialsProducerConstructionData.getMaterialsProducerPropertyValues(); Map propertyValueMap = new LinkedHashMap<>(); materialsProducerPropertyMap.put(materialsProducerId, propertyValueMap); - // PropertyValueRecord propertyValueRecord = - // materialsProducerPropertyMap.get(materialsProducerId).get(materialsProducerPropertyId); - if (checkPropertyCoverage) { - clearNonDefaultProducerChecks(); - for (MaterialsProducerPropertyId materialsProducerPropertyId : materialsProducerPropertyValues.keySet()) { - validateMaterialsProducerPropertyId(materialsProducerPropertyId); - markProducerPropertyAssigned(materialsProducerPropertyId); - Object propertyValue = materialsProducerPropertyValues.get(materialsProducerPropertyId); - final PropertyDefinition propertyDefinition = materialsProducerPropertyDefinitions.get(materialsProducerPropertyId); - validateValueCompatibility(materialsProducerPropertyId, propertyDefinition, propertyValue); - PropertyValueRecord propertyValueRecord = new PropertyValueRecord(dataManagerContext); - propertyValueRecord.setPropertyValue(propertyValue); - propertyValueMap.put(materialsProducerPropertyId, propertyValueRecord); - } - verifyNonDefaultChecksForProducers(); - } else { - for (MaterialsProducerPropertyId materialsProducerPropertyId : materialsProducerPropertyValues.keySet()) { - validateMaterialsProducerPropertyId(materialsProducerPropertyId); - Object propertyValue = materialsProducerPropertyValues.get(materialsProducerPropertyId); - final PropertyDefinition propertyDefinition = materialsProducerPropertyDefinitions.get(materialsProducerPropertyId); - validateValueCompatibility(materialsProducerPropertyId, propertyDefinition, propertyValue); - PropertyValueRecord propertyValueRecord = new PropertyValueRecord(dataManagerContext); - propertyValueRecord.setPropertyValue(propertyValue); - propertyValueMap.put(materialsProducerPropertyId, propertyValueRecord); - } + + for (MaterialsProducerPropertyId materialsProducerPropertyId : materialsProducerPropertyValues.keySet()) { + Object propertyValue = materialsProducerPropertyValues.get(materialsProducerPropertyId); + PropertyValueRecord propertyValueRecord = new PropertyValueRecord(dataManagerContext); + propertyValueRecord.setPropertyValue(propertyValue); + propertyValueMap.put(materialsProducerPropertyId, propertyValueRecord); } Map resourceLevels = materialsProducerConstructionData.getResourceLevels(); @@ -1562,6 +1559,25 @@ private void handleBatchAdditionMutationEvent(DataManagerContext dataManagerCont validateMaterialId(materialId); final double amount = batchConstructionInfo.getAmount(); + final Map propertyValues = batchConstructionInfo.getPropertyValues(); + boolean checkPropertyCoverage = !nonDefaultBearingBatchPropertyIds.get(materialId).isEmpty(); + + for (final BatchPropertyId batchPropertyId : propertyValues.keySet()) { + validateBatchPropertyId(materialId, batchPropertyId); + final Object batchPropertyValue = propertyValues.get(batchPropertyId); + final PropertyDefinition propertyDefinition = batchPropertyDefinitions.get(materialId).get(batchPropertyId); + validateBatchPropertyValueNotNull(batchPropertyValue); + validateValueCompatibility(batchPropertyId, propertyDefinition, batchPropertyValue); + } + + if (checkPropertyCoverage) { + clearNonDefaultBatchChecks(materialId); + for (final BatchPropertyId batchPropertyId : propertyValues.keySet()) { + markBatchPropertyAssigned(materialId, batchPropertyId); + } + verifyNonDefaultBatchChecks(materialId); + } + final MaterialsProducerRecord materialsProducerRecord = materialsProducerMap.get(materialsProducerId); final BatchRecord batchRecord = new BatchRecord(batchId); batchRecord.amount = amount; @@ -1571,40 +1587,14 @@ private void handleBatchAdditionMutationEvent(DataManagerContext dataManagerCont materialsProducerRecord.inventory.add(batchRecord); batchRecords.put(batchRecord.batchId, batchRecord); - boolean checkPropertyCoverage = !nonDefaultBearingBatchPropertyIds.get(materialId).isEmpty(); - final Map map = new LinkedHashMap<>(); batchPropertyMap.put(batchRecord.batchId, map); - if (checkPropertyCoverage) { - clearNonDefaultBatchChecks(materialId); - - final Map propertyValues = batchConstructionInfo.getPropertyValues(); - for (final BatchPropertyId batchPropertyId : propertyValues.keySet()) { - validateBatchPropertyId(materialId, batchPropertyId); - markBatchPropertyAssigned(materialId, batchPropertyId); - final Object batchPropertyValue = propertyValues.get(batchPropertyId); - final PropertyDefinition propertyDefinition = batchPropertyDefinitions.get(materialId).get(batchPropertyId); - validateBatchPropertyValueNotNull(batchPropertyValue); - validateValueCompatibility(batchPropertyId, propertyDefinition, batchPropertyValue); - final PropertyValueRecord propertyValueRecord = new PropertyValueRecord(dataManagerContext); - propertyValueRecord.setPropertyValue(batchPropertyValue); - map.put(batchPropertyId, propertyValueRecord); - } - - verifyNonDefaultBatchChecks(materialId); - } else { - final Map propertyValues = batchConstructionInfo.getPropertyValues(); - for (final BatchPropertyId batchPropertyId : propertyValues.keySet()) { - validateBatchPropertyId(materialId, batchPropertyId); - final Object batchPropertyValue = propertyValues.get(batchPropertyId); - final PropertyDefinition propertyDefinition = batchPropertyDefinitions.get(materialId).get(batchPropertyId); - validateBatchPropertyValueNotNull(batchPropertyValue); - validateValueCompatibility(batchPropertyId, propertyDefinition, batchPropertyValue); - final PropertyValueRecord propertyValueRecord = new PropertyValueRecord(dataManagerContext); - propertyValueRecord.setPropertyValue(batchPropertyValue); - map.put(batchPropertyId, propertyValueRecord); - } + for (final BatchPropertyId batchPropertyId : propertyValues.keySet()) { + final Object batchPropertyValue = propertyValues.get(batchPropertyId); + final PropertyValueRecord propertyValueRecord = new PropertyValueRecord(dataManagerContext); + propertyValueRecord.setPropertyValue(batchPropertyValue); + map.put(batchPropertyId, propertyValueRecord); } if (dataManagerContext.subscribersExist(BatchAdditionEvent.class)) { diff --git a/gcm4/src/main/java/plugins/personproperties/datamanagers/PersonPropertiesDataManager.java b/gcm4/src/main/java/plugins/personproperties/datamanagers/PersonPropertiesDataManager.java index fa86d80c4..324878e2f 100644 --- a/gcm4/src/main/java/plugins/personproperties/datamanagers/PersonPropertiesDataManager.java +++ b/gcm4/src/main/java/plugins/personproperties/datamanagers/PersonPropertiesDataManager.java @@ -105,10 +105,11 @@ private void handlePersonPropertyDefinitionMutationEvent(DataManagerContext data validatePersonPropertyIdIsUnknown(personPropertyId); boolean checkAllPeopleHaveValues = propertyDefinition.getDefaultValue().isEmpty(); - personPropertyDefinitions.put(personPropertyId, propertyDefinition); - final IndexedPropertyManager propertyManager = getIndexedPropertyManager(dataManagerContext, propertyDefinition, 0); - personPropertyManagerMap.put(personPropertyId, propertyManager); - + for (Pair pair : propertyDefinitionInitialization.getPropertyValues()) { + PersonId personId = pair.getFirst(); + validatePersonExists(personId); + } + if (checkAllPeopleHaveValues) { addNonDefaultProperty(personPropertyId); int idLimit = peopleDataManager.getPersonIdLimit(); @@ -117,13 +118,7 @@ private void handlePersonPropertyDefinitionMutationEvent(DataManagerContext data for (Pair pair : propertyDefinitionInitialization.getPropertyValues()) { PersonId personId = pair.getFirst(); int pId = personId.getValue(); - coverageSet.set(pId); - /* - * we do not have to validate the value since it is guaranteed - * to be consistent with the property definition by contract. - */ - Object value = pair.getSecond(); - propertyManager.setPropertyValue(pId, value); + coverageSet.set(pId); } for (int i = 0; i < idLimit; i++) { if (peopleDataManager.personIndexExists(i)) { @@ -133,17 +128,21 @@ private void handlePersonPropertyDefinitionMutationEvent(DataManagerContext data } } } - } else { - for (Pair pair : propertyDefinitionInitialization.getPropertyValues()) { - PersonId personId = pair.getFirst(); - int pId = personId.getValue(); - /* - * we do not have to validate the value since it is guaranteed - * to be consistent with the property definition by contract. - */ - Object value = pair.getSecond(); - propertyManager.setPropertyValue(pId, value); - } + } + + personPropertyDefinitions.put(personPropertyId, propertyDefinition); + final IndexedPropertyManager propertyManager = getIndexedPropertyManager(dataManagerContext, propertyDefinition, 0); + personPropertyManagerMap.put(personPropertyId, propertyManager); + + for (Pair pair : propertyDefinitionInitialization.getPropertyValues()) { + PersonId personId = pair.getFirst(); + int pId = personId.getValue(); + /* + * we do not have to validate the value since it is guaranteed + * to be consistent with the property definition by contract. + */ + Object value = pair.getSecond(); + propertyManager.setPropertyValue(pId, value); } if (dataManagerContext.subscribersExist(PersonPropertyDefinitionEvent.class)) { @@ -612,34 +611,32 @@ private void handlePersonImminentAdditionEvent(final DataManagerContext dataMana List personPropertyAssignments = personConstructionData.getValues(PersonPropertyInitialization.class); - if (nonDefaultBearingPropertyIds.isEmpty()) { - for (final PersonPropertyInitialization personPropertyAssignment : personPropertyAssignments) { - PersonPropertyId personPropertyId = personPropertyAssignment.getPersonPropertyId(); - final Object personPropertyValue = personPropertyAssignment.getValue(); - validatePersonPropertyId(personPropertyId); - validatePersonPropertyValueNotNull(personPropertyValue); - final PropertyDefinition propertyDefinition = personPropertyDefinitions.get(personPropertyId); - validateValueCompatibility(personPropertyId, propertyDefinition, personPropertyValue); - int pId = personId.getValue(); - IndexedPropertyManager propertyManager = personPropertyManagerMap.get(personPropertyId); - propertyManager.setPropertyValue(pId, personPropertyValue); - } - } else { + + for (final PersonPropertyInitialization personPropertyAssignment : personPropertyAssignments) { + PersonPropertyId personPropertyId = personPropertyAssignment.getPersonPropertyId(); + final Object personPropertyValue = personPropertyAssignment.getValue(); + validatePersonPropertyId(personPropertyId); + validatePersonPropertyValueNotNull(personPropertyValue); + final PropertyDefinition propertyDefinition = personPropertyDefinitions.get(personPropertyId); + validateValueCompatibility(personPropertyId, propertyDefinition, personPropertyValue); + } + + if (!nonDefaultBearingPropertyIds.isEmpty()) { clearNonDefaultChecks(); for (final PersonPropertyInitialization personPropertyAssignment : personPropertyAssignments) { PersonPropertyId personPropertyId = personPropertyAssignment.getPersonPropertyId(); markAssigned(personPropertyId); - final Object personPropertyValue = personPropertyAssignment.getValue(); - validatePersonPropertyId(personPropertyId); - validatePersonPropertyValueNotNull(personPropertyValue); - final PropertyDefinition propertyDefinition = personPropertyDefinitions.get(personPropertyId); - validateValueCompatibility(personPropertyId, propertyDefinition, personPropertyValue); - int pId = personId.getValue(); - IndexedPropertyManager propertyManager = personPropertyManagerMap.get(personPropertyId); - propertyManager.setPropertyValue(pId, personPropertyValue); } verifyNonDefaultChecks(); } + + for (final PersonPropertyInitialization personPropertyAssignment : personPropertyAssignments) { + PersonPropertyId personPropertyId = personPropertyAssignment.getPersonPropertyId(); + final Object personPropertyValue = personPropertyAssignment.getValue(); + int pId = personId.getValue(); + IndexedPropertyManager propertyManager = personPropertyManagerMap.get(personPropertyId); + propertyManager.setPropertyValue(pId, personPropertyValue); + } } diff --git a/gcm4/src/main/java/plugins/regions/datamanagers/RegionsDataManager.java b/gcm4/src/main/java/plugins/regions/datamanagers/RegionsDataManager.java index d3614ffc1..703808bf6 100644 --- a/gcm4/src/main/java/plugins/regions/datamanagers/RegionsDataManager.java +++ b/gcm4/src/main/java/plugins/regions/datamanagers/RegionsDataManager.java @@ -202,25 +202,20 @@ private void handleRegionAdditionMutationEvent(DataManagerContext dataManagerCon RegionId regionId = regionConstructionData.getRegionId(); validateNewRegionId(regionId); Map regionPropertyValues = regionConstructionData.getRegionPropertyValues(); - + for (RegionPropertyId regionPropertyId : regionPropertyValues.keySet()) { + validateRegionPropertyId(regionPropertyId); + Object regionPropertyValue = regionPropertyValues.get(regionPropertyId); + final PropertyDefinition propertyDefinition = regionPropertyDefinitions.get(regionPropertyId); + validateValueCompatibility(regionPropertyId, propertyDefinition, regionPropertyValue); + } + if (!nonDefaultBearingPropertyIds.isEmpty()) { clearNonDefaultChecks(); for (RegionPropertyId regionPropertyId : regionPropertyValues.keySet()) { - validateRegionPropertyId(regionPropertyId); markAssigned(regionPropertyId); - Object regionPropertyValue = regionPropertyValues.get(regionPropertyId); - final PropertyDefinition propertyDefinition = regionPropertyDefinitions.get(regionPropertyId); - validateValueCompatibility(regionPropertyId, propertyDefinition, regionPropertyValue); } verifyNonDefaultChecks(); - }else { - for (RegionPropertyId regionPropertyId : regionPropertyValues.keySet()) { - validateRegionPropertyId(regionPropertyId); - Object regionPropertyValue = regionPropertyValues.get(regionPropertyId); - final PropertyDefinition propertyDefinition = regionPropertyDefinitions.get(regionPropertyId); - validateValueCompatibility(regionPropertyId, propertyDefinition, regionPropertyValue); - } - } + } regionPopulationRecordMap.put(regionId, new PopulationRecord()); regionToIndexMap.put(regionId, regionToIndexMap.size() + 1);