<commit_before>/*
 * Copyright 2015 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
 *
 *      http://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.gradle.jvm.internal;

import java.util.Arrays;
import java.util.List;

/**
 * An immutable representation of a valid Java package name.
 *
 * <p>While {@code PackageName} values are guaranteed to be valid per JLS package naming
 * rules, no validation is performed to ensure that the named package actually exists.</p>
 *
 * <p>Note that due to vagaries inherent in Java naming, a valid package name is also
 * always a valid type name.</p>
 *
 * @see #of(String)
 * @since 2.9
 */
final class PackageName {

    private static final List<String> JAVA_KEYWORDS = Arrays.asList(
        "abstract", "assert", "boolean", "break", "byte", "case", "catch", "char", "class", "const", "continue",
        "default", "do", "double", "else", "enum", "extends", "final", "finally", "float", "for", "goto", "if",
        "implements", "import", "instanceof", "int", "interface", "long", "native", "new", "package", "private",
        "protected", "public", "return", "short", "static", "strictfp", "super", "switch", "synchronized", "this",
        "throw", "throws", "transient", "try", "void", "volatile", "while"
    );

    private static final List<String> BOOLEAN_AND_NULL_LITERALS = Arrays.asList("true", "false", "null");

    private static final String UNNAMED_PACKAGE = "";

    private final String value;

    private PackageName(String value) {
        this.value = value;
    }

    /**
     * Validate, create and return a new {@code PackageName} instance from the given
     * package name.
     *
     * <p>See JLS sections:
     * <ul>
     *   <li><em><a href="https://docs.oracle.com/javase/specs/jls/se7/html/jls-3.html#jls-3.8">
     *     3.8. Identifiers</a></em></li>
     *   <li><em><a href="https://docs.oracle.com/javase/specs/jls/se7/html/jls-6.html#jls-6.2">
     *     6.2. Names and Identifiers</a></em></li>
     *   <li><em><a href="https://docs.oracle.com/javase/specs/jls/se7/html/jls-7.html#jls-7.4"><commit_msg>Remove final modifier from PackageName class<commit_after>/*
 * Copyright 2015 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
 *
 *      http://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.gradle.jvm.internal;

import java.util.Arrays;
import java.util.List;

/**
 * An immutable representation of a valid Java package name.
 *
 * <p>While {@code PackageName} values are guaranteed to be valid per JLS package naming
 * rules, no validation is performed to ensure that the named package actually exists.</p>
 *
 * <p>Note that due to vagaries inherent in Java naming, a valid package name is also
 * always a valid type name.</p>
 *
 * @see #of(String)
 * @since 2.9
 */
class PackageName {

    private static final List<String> JAVA_KEYWORDS = Arrays.asList(
        "abstract", "assert", "boolean", "break", "byte", "case", "catch", "char", "class", "const", "continue",
        "default", "do", "double", "else", "enum", "extends", "final", "finally", "float", "for", "goto", "if",
        "implements", "import", "instanceof", "int", "interface", "long", "native", "new", "package", "private",
        "protected", "public", "return", "short", "static", "strictfp", "super", "switch", "synchronized", "this",
        "throw", "throws", "transient", "try", "void", "volatile", "while"
    );

    private static final List<String> BOOLEAN_AND_NULL_LITERALS = Arrays.asList("true", "false", "null");

    private static final String UNNAMED_PACKAGE = "";

    private final String value;

    private PackageName(String value) {
        this.value = value;
    }

    /**
     * Validate, create and return a new {@code PackageName} instance from the given
     * package name.
     *
     * <p>See JLS sections:
     * <ul>
     *   <li><em><a href="https://docs.oracle.com/javase/specs/jls/se7/html/jls-3.html#jls-3.8">
     *     3.8. Identifiers</a></em></li>
     *   <li><em><a href="https://docs.oracle.com/javase/specs/jls/se7/html/jls-6.html#jls-6.2">
     *     6.2. Names and Identifiers</a></em></li>
     *   <li><em><a href="https://docs.oracle.com/javase/specs/jls/se7/html/jls-7.html#jls-7.4">
{'fraction_non_alphanumeric': 0.1532242540904716, 'fraction_numerical': 0.010009624639076035, 'mean_word_length': 3.483175150992235, 'pattern_counts': {'":': 0, '<': 49, '<?xml version=': 0, '>': 49, 'https://': 6, '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': '682570', 'n_tokens_mistral': 1646, 'n_tokens_neox': 1600, 'n_words': 527}