<commit_before>package com.github.anno4j.rdfs_parser.building.support;

import com.github.anno4j.annotations.Partial;
import com.github.anno4j.model.impl.ResourceObject;
import com.github.anno4j.model.namespaces.RDFS;
import com.github.anno4j.model.namespaces.XSD;
import com.github.anno4j.rdfs_parser.building.OntGenerationConfig;
import com.github.anno4j.rdfs_parser.model.ExtendedRDFSClazz;
import com.github.anno4j.rdfs_parser.model.ExtendedRDFSProperty;
import com.github.anno4j.rdfs_parser.model.RDFSClazzSupport;
import com.github.anno4j.rdfs_parser.naming.ClassNameBuilder;
import com.github.anno4j.rdfs_parser.naming.IdentifierBuilder;
import com.squareup.javapoet.ClassName;

import java.net.URISyntaxException;

/**
 * Support class for {@link ExtendedRDFSClazz} implementing basic methods
 * for JavaPoet class generation for this class.
 */
@Partial
public abstract class ClazzBuildingSupport extends RDFSClazzSupport implements ExtendedRDFSClazz {

    @Override
    public String getJavaPackageName() {
        try {
            return ClassNameBuilder.builder(getResourceAsString()).packageName();
        } catch (URISyntaxException e) {
            return "";
        }
    }

    @Override
    public ClassName getJavaPoetClassName(OntGenerationConfig config) {
        if (getResourceAsString().equals(RDFS.CLAZZ) || getResourceAsString().equals(RDFS.RESOURCE)) {
            return ClassName.get(ResourceObject.class);

        }

        // Capture XSD datatypes:
        if (getResourceAsString().startsWith(XSD.NS)) {
            switch (getResourceAsString()) {
                case XSD.STRING:
                    return ClassName.get(String.class);
                case XSD.BOOLEAN:
                    return ClassName.get(Boolean.class);
                case XSD.DECIMAL:
                    return ClassName.get(Double.class);
                case XSD.FLOAT:
                    return ClassName.get(Float.class);
                case XSD.DOUBLE:
                    return ClassName.get(Double.class);
                case XSD.HEX_BINARY:
                    return ClassName.get(String.class);
                case XSD.BASE64_BINARY:
                    return ClassName.get(String.class);
                case XSD.ANY_URI:
                    return ClassName.get(String.class);
                case XSD.NORMALIZED_STRING:
                    return ClassName.get(String.class);
                case XSD.TOKEN:
                    return ClassName.get(String.class);
                case XSD.LANGUAGE:
                    return ClassName.get(String.class);
                case XSD.INTEGER:
                    return ClassName.get(Integer.class);
                case XSD.NON_POSITIVE_INTEGER:
                    return ClassName.get(Integer.class);
                case XSD.NEGATIVE_INTEGER:
                    return ClassName.get(Integer.class);
                case XSD.LONG:
                    return ClassName.get(Long.class);
                case XSD.INT:
                    return ClassName.get(Integer.class);
                case XSD.SHORT:
                    return ClassName.get(Short.class);
                case XSD.BYTE:
                    return ClassName.get(Byte.class);
                case XSD.NON_NEGATIVE_INTEGER:
                    return ClassName.get(Integer.class);
                case XSD.UNSIGNED_LONG:
                    return ClassName.get(Long.class);
                case XSD.UNSIGNED_INT:
                    return ClassName.get(Integer.class);
                case XSD.UNSIGNED_SHORT:
                    return ClassName.get(Short.class);
                case XSD.UNSIGNED_BYTE:
                    return ClassName.get(Byte.class);
                case XSD.POSITIVE_INTEGER:
                    return ClassName.get(Integer.class);
                default:
                    return ClassName.get(String.class);
            }
        }

        // First try to find a name for this class:
        try {
            ClassNameBuilder nameBuilder = ClassNameBuilder.builder(getResourceAsString());

            // Identifier building is enhanced by rdfs:label literals:
            if (getLabels() != null && !getLabels().isEmpty()) {
                CharSequence preferredLabel = getPreferredRDFSLabel(config);
                if (preferredLabel != null) {
                    nameBuilder = nameBuilder.withRDFSLabel(preferredLabel.toString());
                }
            }

            // Add information about incoming and outgoing properties:
            for (ExtendedRDFSProperty incomingProp : getIncomingProperties()) {<commit_msg>Changed parameter type to wildcard for CharSequence (see issue #130).<commit_after>package com.github.anno4j.rdfs_parser.building.support;

import com.github.anno4j.annotations.Partial;
import com.github.anno4j.model.impl.ResourceObject;
import com.github.anno4j.model.namespaces.RDFS;
import com.github.anno4j.model.namespaces.XSD;
import com.github.anno4j.rdfs_parser.building.OntGenerationConfig;
import com.github.anno4j.rdfs_parser.model.ExtendedRDFSClazz;
import com.github.anno4j.rdfs_parser.model.ExtendedRDFSProperty;
import com.github.anno4j.rdfs_parser.model.RDFSClazzSupport;
import com.github.anno4j.rdfs_parser.naming.ClassNameBuilder;
import com.github.anno4j.rdfs_parser.naming.IdentifierBuilder;
import com.squareup.javapoet.ClassName;

import java.net.URISyntaxException;

/**
 * Support class for {@link ExtendedRDFSClazz} implementing basic methods
 * for JavaPoet class generation for this class.
 */
@Partial
public abstract class ClazzBuildingSupport extends RDFSClazzSupport implements ExtendedRDFSClazz {

    @Override
    public String getJavaPackageName() {
        try {
            return ClassNameBuilder.builder(getResourceAsString()).packageName();
        } catch (URISyntaxException e) {
            return "";
        }
    }

    @Override
    public ClassName getJavaPoetClassName(OntGenerationConfig config) {
        if (getResourceAsString().equals(RDFS.CLAZZ) || getResourceAsString().equals(RDFS.RESOURCE)) {
            return ClassName.get(ResourceObject.class);

        }

        // Capture XSD datatypes:
        if (getResourceAsString().startsWith(XSD.NS)) {
            switch (getResourceAsString()) {
                case XSD.STRING:
                    return ClassName.get(CharSequence.class);
                case XSD.BOOLEAN:
                    return ClassName.get(Boolean.class);
                case XSD.DECIMAL:
                    return ClassName.get(Double.class);
                case XSD.FLOAT:
                    return ClassName.get(Float.class);
                case XSD.DOUBLE:
                    return ClassName.get(Double.class);
                case XSD.HEX_BINARY:
                    return ClassName.get(String.class);
                case XSD.BASE64_BINARY:
                    return ClassName.get(String.class);
                case XSD.ANY_URI:
                    return ClassName.get(CharSequence.class);
                case XSD.NORMALIZED_STRING:
                    return ClassName.get(CharSequence.class);
                case XSD.TOKEN:
                    return ClassName.get(CharSequence.class);
                case XSD.LANGUAGE:
                    return ClassName.get(String.class);
                case XSD.INTEGER:
                    return ClassName.get(Integer.class);
                case XSD.NON_POSITIVE_INTEGER:
                    return ClassName.get(Integer.class);
                case XSD.NEGATIVE_INTEGER:
                    return ClassName.get(Integer.class);
                case XSD.LONG:
                    return ClassName.get(Long.class);
                case XSD.INT:
                    return ClassName.get(Integer.class);
                case XSD.SHORT:
                    return ClassName.get(Short.class);
                case XSD.BYTE:
                    return ClassName.get(Byte.class);
                case XSD.NON_NEGATIVE_INTEGER:
                    return ClassName.get(Integer.class);
                case XSD.UNSIGNED_LONG:
                    return ClassName.get(Long.class);
                case XSD.UNSIGNED_INT:
                    return ClassName.get(Integer.class);
                case XSD.UNSIGNED_SHORT:
                    return ClassName.get(Short.class);
                case XSD.UNSIGNED_BYTE:
                    return ClassName.get(Byte.class);
                case XSD.POSITIVE_INTEGER:
                    return ClassName.get(Integer.class);
                default:
                    return ClassName.get(CharSequence.class);
            }
        }

        // First try to find a name for this class:
        try {
            ClassNameBuilder nameBuilder = ClassNameBuilder.builder(getResourceAsString());

            // Identifier building is enhanced by rdfs:label literals:
            if (getLabels() != null && !getLabels().isEmpty()) {
                CharSequence preferredLabel = getPreferredRDFSLabel(config);
                if (preferredLabel != null) {
                    nameBuilder = nameBuilder.withRDFSLabel(preferredLabel.toString());
                }
            }

            // Add information about incoming and outgoing properties:
            for (ExtendedRDFSProperty incomingProp : getIncomingProperties()) {
{'fraction_non_alphanumeric': 0.0838336192109777, 'fraction_numerical': 0.003108919382504288, 'mean_word_length': 1.8572741194486984, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '1896350', 'n_tokens_mistral': 2574, 'n_tokens_neox': 2409, 'n_words': 449}