<commit_before>package org.jnosql.artemis.column;

import org.jnosql.artemis.reflection.ClassInformationNotFoundException;
import org.jnosql.artemis.reflection.ClassRepresentations;
import org.jnosql.diana.api.column.ColumnEntity;
import org.jnosql.diana.api.column.ColumnFamilyManager;
import org.jnosql.diana.api.column.ColumnPreparedStatement;
import org.jnosql.diana.api.column.ColumnQueryParser;

import java.util.List;

final class MapperColumnQueryParser implements ColumnQueryParser {

    private final ColumnQueryParser parser = ColumnQueryParser.getParser();

    private final ClassRepresentations representations;

    MapperColumnQueryParser(ClassRepresentations representations) {
        this.representations = representations;
    }

    @Override
    public List<ColumnEntity> query(String query, ColumnFamilyManager manager) {
        return parser.query(query, manager);
    }

    @Override
    public ColumnPreparedStatement prepare(String query, ColumnFamilyManager manager) {
        return parser.prepare(query, manager);
    }

    public String fireEntity(String entity) {
        try {
            representations.findBySimpleClassName(entity);
        } catch (ClassInformationNotFoundException e) {
            return entity;
        }
    }

    public String fireField(String entity, String field) {
        return field;
    }

}<commit_msg>implementes parsre<commit_after>package org.jnosql.artemis.column;

import org.jnosql.artemis.reflection.ClassInformationNotFoundException;
import org.jnosql.artemis.reflection.ClassRepresentation;
import org.jnosql.artemis.reflection.ClassRepresentations;
import org.jnosql.diana.api.column.ColumnEntity;
import org.jnosql.diana.api.column.ColumnFamilyManager;
import org.jnosql.diana.api.column.ColumnPreparedStatement;
import org.jnosql.diana.api.column.ColumnQueryParser;

import java.util.List;
import java.util.Optional;

final class MapperColumnQueryParser implements ColumnQueryParser {

    private final ColumnQueryParser parser = ColumnQueryParser.getParser();

    private final ClassRepresentations representations;

    MapperColumnQueryParser(ClassRepresentations representations) {
        this.representations = representations;
    }

    @Override
    public List<ColumnEntity> query(String query, ColumnFamilyManager manager) {
        return parser.query(query, manager);
    }

    @Override
    public ColumnPreparedStatement prepare(String query, ColumnFamilyManager manager) {
        return parser.prepare(query, manager);
    }

    public String fireEntity(String entity) {
        Optional<ClassRepresentation> classRepresentation = getClassRepresentation(entity);
        return classRepresentation.map(ClassRepresentation::getName).orElse(entity);
    }

    public String fireField(String entity, String field) {
        Optional<ClassRepresentation> classRepresentation = getClassRepresentation(entity);
        return classRepresentation.map(c -> c.getColumnField(field)).orElse(field);
    }

    private Optional<ClassRepresentation> getClassRepresentation(String entity) {
        Optional<ClassRepresentation> bySimpleName = representations.findBySimpleName(entity);
        if (bySimpleName.isPresent()) {
            return bySimpleName;
        }
        Optional<ClassRepresentation> byClassName = representations.findByClassName(entity);
        if (byClassName.isPresent()) {
            return byClassName;
        }
        return Optional.empty();
    }
}
{'fraction_non_alphanumeric': 0.07968929804372843, 'fraction_numerical': 0.0, 'mean_word_length': 4.228571428571429, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 11, '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': '1922571', 'n_tokens_mistral': 924, 'n_tokens_neox': 889, 'n_words': 173}