<commit_before>/*
 * Copyright 2002-2022 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.springframework.aot.generate;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;

import org.springframework.aot.hint.RuntimeHints;
import org.springframework.util.Assert;

/**
 * Default {@link GenerationContext} implementation.
 *
 * <p>Generated classes can be flushed out using {@link #writeGeneratedContent()}
 * which should be called only once after the generation process using this instance
 * has completed.
 *
 * @author <NAME>
 * @author <NAME>
 * @since 6.0
 */
public class DefaultGenerationContext implements GenerationContext {

	private final Map<String, AtomicInteger> sequenceGenerator;

	private final GeneratedClasses generatedClasses;

	private final GeneratedFiles generatedFiles;

	private final RuntimeHints runtimeHints;


	/**
	 * Create a new {@link DefaultGenerationContext} instance backed by the
	 * specified {@link ClassNameGenerator} and {@link GeneratedFiles}.
	 * @param classNameGenerator the naming convention to use for generated
	 * class names
	 * @param generatedFiles the generated files
	 */
	public DefaultGenerationContext(ClassNameGenerator classNameGenerator, GeneratedFiles generatedFiles) {
		this(new GeneratedClasses(classNameGenerator), generatedFiles, new RuntimeHints());
	}

	/**
	 * Create a new {@link DefaultGenerationContext} instance backed by the
	 * specified items.
	 * @param generatedClasses the generated classes
	 * @param generatedFiles the generated files
	 * @param runtimeHints the runtime hints
	 */
	public DefaultGenerationContext(GeneratedClasses generatedClasses,
			GeneratedFiles generatedFiles, RuntimeHints runtimeHints) {
		Assert.notNull(generatedClasses, "'generatedClasses' must not be null");
		Assert.notNull(generatedFiles, "'generatedFiles' must not be null");
		Assert.notNull(runtimeHints, "'runtimeHints' must not be null");
		this.sequenceGenerator = new ConcurrentHashMap<>();
		this.generatedClasses = generatedClasses;
		this.generatedFiles = generatedFiles;
		this.runtimeHints = runtimeHints;<commit_msg>Make DefaultGenerationContext(GeneratedClasses,...) package private<commit_after>/*
 * Copyright 2002-2022 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.springframework.aot.generate;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;

import org.springframework.aot.hint.RuntimeHints;
import org.springframework.util.Assert;

/**
 * Default {@link GenerationContext} implementation.
 *
 * <p>Generated classes can be flushed out using {@link #writeGeneratedContent()}
 * which should be called only once after the generation process using this instance
 * has completed.
 *
 * @author <NAME>
 * @author <NAME>
 * @since 6.0
 */
public class DefaultGenerationContext implements GenerationContext {

	private final Map<String, AtomicInteger> sequenceGenerator;

	private final GeneratedClasses generatedClasses;

	private final GeneratedFiles generatedFiles;

	private final RuntimeHints runtimeHints;


	/**
	 * Create a new {@link DefaultGenerationContext} instance backed by the
	 * specified {@link ClassNameGenerator} and {@link GeneratedFiles}.
	 * @param classNameGenerator the naming convention to use for generated
	 * class names
	 * @param generatedFiles the generated files
	 */
	public DefaultGenerationContext(ClassNameGenerator classNameGenerator, GeneratedFiles generatedFiles) {
		this(new GeneratedClasses(classNameGenerator), generatedFiles, new RuntimeHints());
	}

	/**
	 * Create a new {@link DefaultGenerationContext} instance backed by the
	 * specified items.
	 * @param generatedClasses the generated classes
	 * @param generatedFiles the generated files
	 * @param runtimeHints the runtime hints
	 */
	DefaultGenerationContext(GeneratedClasses generatedClasses,
			GeneratedFiles generatedFiles, RuntimeHints runtimeHints) {
		Assert.notNull(generatedClasses, "'generatedClasses' must not be null");
		Assert.notNull(generatedFiles, "'generatedFiles' must not be null");
		Assert.notNull(runtimeHints, "'runtimeHints' must not be null");
		this.sequenceGenerator = new ConcurrentHashMap<>();
		this.generatedClasses = generatedClasses;
		this.generatedFiles = generatedFiles;
		this.runtimeHints = runtimeHints;
{'fraction_non_alphanumeric': 0.07943159045363454, 'fraction_numerical': 0.005101111313536163, 'mean_word_length': 5.11358574610245, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4337099', 'n_tokens_mistral': 1390, 'n_tokens_neox': 1302, 'n_words': 511}