Finalize the mapping and make sure that it is consistent.

@throws MappingException if inconsistencies are discovered.
192349
public function validateClassMapping()
    {
        // associative array fields need a separate property to store the keys.
        // make sure that generated or specified name does not collide with an
        // existing mapping.
        $assocFields = [];
        foreach ($this->fieldMappings as $fieldName) {
            $mapping = $this->mappings[$fieldName];
            if (empty($mapping['assoc'])) {
                continue;
            }

            if (isset($this->mappings[$mapping['assoc']])) {
                throw MappingException::assocOverlappingFieldDefinition($this->name, $fieldName, $mapping['assoc']);
            }

            if (!empty($assocFields[$mapping['assoc']])) {
                throw MappingException::assocOverlappingAssocDefinition($this->name, $fieldName, $assocFields[$mapping['assoc']]);
            }

            $assocFields[$mapping['assoc']] = $fieldName;
        }

        if (!empty($this->versionNameField) && !$this->versionable) {
            throw new MappingException(sprintf(
                'You cannot use the @VersionName annotation on the non-versionable document %s (field = %s)',
                $this->name,
                $this->versionNameField
            ));
        }

        if (!empty($this->versionCreatedField) && !$this->versionable) {
            throw new MappingException(sprintf(
                'You cannot use the @VersionCreated annotation on the non-versionable document %s (field = %s)',
                $this->name,
                $this->versionCreatedField
            ));
        }

        if (count($this->translatableFields)) {
            if (!isset($this->localeMapping)) {
                throw new MappingException(sprintf(
                    'You must define a locale mapping for translatable document "%s"',
                    $this->name
                ));
            }
        }

        // we allow mixed referrers on non-referenceable documents. maybe the mix:referenceable is just not mapped
        if (count($this->referrersMappings)) {
            if (!$this->referenceable) {
                throw new MappingException(sprintf(
                    'You can not have referrers mapped on document "%s" as the document is not referenceable',
                    $this->name
                ));
            }

            foreach ($this->referrersMappings as $referrerName) {
                $mapping = $this->mappings[$referrerName];
                // only a santiy check with reflection. otherwise we could run into endless loops
                if (!ClassLoader::classExists($mapping['referringDocument'])) {
                    throw new MappingException(sprintf(
                        'Invalid referrer mapping on document "%s" for field "%s": The referringDocument class "%s" does not exist',
                        $this->name,
                        $mapping['fieldName'],
                        $mapping['referringDocument']
                    ));
                }
                $reflection = new ReflectionClass($mapping['referringDocument']);
                if (!$reflection->hasProperty($mapping['referencedBy'])) {
                    throw new MappingException(sprintf(
                        'Invalid referrer mapping on document "%s" for field "%s": The referringDocument "%s" has no property "%s"',
                        $this->name,
                        $mapping['fieldName'],
                        $mapping['referringDocument'],
                        $mapping['referencedBy']
                    ));
                }
            }
        }

        $this->validateIdentifier();
    }
274546
public function validateIdentifier()
    {
        if ($this->isMappedSuperclass || $this->isEmbeddedClass) {
            return;
        }

        // Verify & complete identifier mapping
        if ( ! $this->identifier) {
            throw MappingException::identifierRequired($this->name);
        }

        if ($this->usesIdGenerator() && $this->isIdentifierComposite) {
            throw MappingException::compositeKeyAssignedIdGeneratorRequired($this->name);
        }
    }
1010350
public function setInheritanceType($type) : void
    {
        if (! $this->isInheritanceType($type)) {
            throw MappingException::invalidInheritanceType($this->className, $type);
        }

        $this->inheritanceType = $type;
    }
1274864
@Override // FSDatasetInterface
  public void finalizeBlock(int namespaceId, Block b) throws IOException {
    finalizeBlockInternal(namespaceId, b, true);
  }
590780
def finalize(self):
        
        logger.debug("Finalizing: {}".format(self))

        # Disconnect signals
        self.collector.sigContentsChanged.disconnect(self.collectorContentsChanged)
        self._configTreeModel.sigItemChanged.disconnect(self.configContentsChanged)
        self.sigInspectorChanged.disconnect(self.inspectorSelectionPane.updateFromInspectorRegItem)
        self.customContextMenuRequested.disconnect(self.showContextMenu)
427505
private void closeMappedEntity(final MappedEntity mappedEntity) {

        try {
            // Flush first
            final PreparedStatement insert = mappedEntity.getInsert();
            final PreparedStatement insertReturning = mappedEntity.getInsertReturning();
            final PreparedStatement insertWithAutoInc = mappedEntity.getInsertWithAutoInc();

            insert.executeBatch();

            if (insertReturning != null) {
                insertReturning.executeBatch();
            }

            if (insertWithAutoInc != null) {
                insertWithAutoInc.executeBatch();
            }

        } catch (final SQLException e) {
            logger.debug(String.format("Failed to flush before closing mapped entity '%s'",
                    mappedEntity.getEntity().getName()), e);

        } finally {
            try {
                mappedEntity.close();
            } catch (final Exception e) {
                logger.warn("Could not close insert statements from mapped entity.", e);
            }
        }

    }
405351
private void flushComplete(long lastIndexedOffset) {
        this.aggregator.reset();
        this.aggregator.setLastIndexedOffset(lastIndexedOffset);
        this.connector.notifyIndexOffsetChanged(this.aggregator.getLastIndexedOffset());
        log.debug("{}: FlushComplete (State={}).", this.traceObjectId, this.aggregator);
    }
784484
@Override
	public void close() {
		synchronized (this) {
			if (object != null) {
				T object_ = object;
				object = null;
				try {
					finalizer.accept(object_);
				} catch (Exception e) {
					// Ignored
				}
			}
		}
	}
452446
def finalize(self):
        
        self.spinBox.valueChanged.disconnect(self.commitChangedValue)
        super(IntCtiEditor, self).finalize()
712178
public void finalizeConfig() {
        // See if not set by configuration, if there are defaults
        // in order from the Endpoint, Service, or Bus.

        configureConduitFromEndpointInfo(this, endpointInfo);
        logConfig();

        if (getClient().getDecoupledEndpoint() != null) {
            this.endpointInfo.setProperty("org.apache.cxf.ws.addressing.replyto",
                                          getClient().getDecoupledEndpoint());
        }
    }
823993
private void finalizeNameAssignment(Assignment a, String newName) {
    a.setNewName(newName);

    // Keep track of the mapping
    renameMap.put(a.oldName, newName);
  }
695664
private void initMappings() throws Exception {
        checkClient();
        // We extract indexes and mappings to manage from mappings definition
        if (mappings != null && mappings.length > 0) {
            Map<String, Collection<String>> indices = getIndexMappings(mappings);

            // Let's initialize indexes and mappings if needed
            for (String index : indices.keySet()) {
                createIndex(client.getLowLevelClient(), classpathRoot, index, forceMapping);
                if (mergeSettings) {
                    updateSettings(client.getLowLevelClient(), classpathRoot, index);
                }

                createMapping(client, classpathRoot, index, mergeMapping);
            }
        }
    }
1023690
public void finalizeConfig() {
        assert !configFinalized;

        try {
            retrieveEngine();
        } catch (Exception e) {
            throw new RuntimeException(e.getMessage(), e);
        }
        configFinalized = true;
    }
1049663
public function finalize()
    {
        if (!$this->finalized) {
            foreach ($this->getRoutes() as $route) {
                $route->finalize();
                $this->addRoute($route->getMethods(), $route->getPattern(), [$route, 'run']);
            }
            $this->finalized = true;
        }
    }
503045
private void complete(T result, Throwable error) {
    synchronized (orderedFutures) {
      this.result = result;
      this.error = error;
      this.complete = true;
      if (error == null) {
        for (CompletableFuture<T> future : orderedFutures) {
          future.complete(result);
        }
      } else {
        for (CompletableFuture<T> future : orderedFutures) {
          future.completeExceptionally(error);
        }
      }
      orderedFutures.clear();
    }
  }
794663
private void complete() {
        if (upToDate) {
            // No rules were added since last time.
            return;
        }

        // Make sure either no final rules or a pair of AnnualTimeZoneRules
        // are available.
        if (finalRules != null && finalRules[1] == null) {
            throw new IllegalStateException("Incomplete final rules");
        }

        // Create a TimezoneTransition and add to the list
        if (historicRules != null || finalRules != null) {
            TimeZoneRule curRule = initialRule;
            long lastTransitionTime = Grego.MIN_MILLIS;

            // Build the transition array which represents historical time zone
            // transitions.
            if (historicRules != null) {
                BitSet done = new BitSet(historicRules.size()); // for skipping rules already processed

                while (true) {
                    int curStdOffset = curRule.getRawOffset();
                    int curDstSavings = curRule.getDSTSavings();
                    long nextTransitionTime = Grego.MAX_MILLIS;
                    TimeZoneRule nextRule = null;
                    Date d;
                    long tt;

                    for (int i = 0; i < historicRules.size(); i++) {
                        if (done.get(i)) {
                            continue;
                        }
                        TimeZoneRule r = historicRules.get(i);
                        d = r.getNextStart(lastTransitionTime, curStdOffset, curDstSavings, false);
                        if (d == null) {
                            // No more transitions from this rule - skip this rule next time
                            done.set(i);
                        } else {
                            if (r == curRule ||
                                    (r.getName().equals(curRule.getName())
                                            && r.getRawOffset() == curRule.getRawOffset()
                                            && r.getDSTSavings() == curRule.getDSTSavings())) {
                                continue;
                            }
                            tt = d.getTime();
                            if (tt < nextTransitionTime) {
                                nextTransitionTime = tt;
                                nextRule = r;
                            }
                        }
                    }

                    if (nextRule ==  null) {
                        // Check if all historic rules are done
                        boolean bDoneAll = true;
                        for (int j = 0; j < historicRules.size(); j++) {
                            if (!done.get(j)) {
                                bDoneAll = false;
                                break;
                            }
                        }
                        if (bDoneAll) {
                            break;
                        }
                    }

                    if (finalRules != null) {
                        // Check if one of final rules has earlier transition date
                        for (int i = 0; i < 2 /* finalRules.length */; i++) {
                            if (finalRules[i] == curRule) {
                                continue;
                            }
                            d = finalRules[i].getNextStart(lastTransitionTime, curStdOffset, curDstSavings, false);
                            if (d != null) {
                                tt = d.getTime();
                                if (tt < nextTransitionTime) {
                                    nextTransitionTime = tt;
                                    nextRule = finalRules[i];
                                }
                            }
                        }
                    }

                    if (nextRule == null) {
                        // Nothing more
                        break;
                    }

                    if (historicTransitions == null) {
                        historicTransitions = new ArrayList<TimeZoneTransition>();
                    }
                    historicTransitions.add(new TimeZoneTransition(nextTransitionTime, curRule, nextRule));
                    lastTransitionTime = nextTransitionTime;
                    curRule = nextRule;
                }
            }
            if (finalRules != null) {
                if (historicTransitions == null) {
                    historicTransitions = new ArrayList<TimeZoneTransition>();
                }
                // Append the first transition for each
                Date d0 = finalRules[0].getNextStart(lastTransitionTime, curRule.getRawOffset(), curRule.getDSTSavings(), false);
                Date d1 = finalRules[1].getNextStart(lastTransitionTime, curRule.getRawOffset(), curRule.getDSTSavings(), false);
                if (d1.after(d0)) {
                    historicTransitions.add(new TimeZoneTransition(d0.getTime(), curRule, finalRules[0]));
                    d1 = finalRules[1].getNextStart(d0.getTime(), finalRules[0].getRawOffset(), finalRules[0].getDSTSavings(), false);
                    historicTransitions.add(new TimeZoneTransition(d1.getTime(), finalRules[0], finalRules[1]));
                } else {
                    historicTransitions.add(new TimeZoneTransition(d1.getTime(), curRule, finalRules[1]));
                    d0 = finalRules[0].getNextStart(d1.getTime(), finalRules[1].getRawOffset(), finalRules[1].getDSTSavings(), false);
                    historicTransitions.add(new TimeZoneTransition(d0.getTime(), finalRules[1], finalRules[0]));
                }
            }
        }
        upToDate = true;
    }
856986
public function on_elements_end() {

        foreach ($this->mappings as $mapping) {
            $this->write_xml('workshopform_numerrors_map', $mapping, array('/workshopform_numerrors_map/id'));
        }

        foreach ($this->dimensions as $dimension) {
            $this->write_xml('workshopform_numerrors_dimension', $dimension, array('/workshopform_numerrors_dimension/id'));
        }
    }