<commit_before>/*
 *  Copyright (c) 2019 <NAME> and others
 *   All rights reserved. This program and the accompanying materials
 *   are made available under the terms of the Eclipse Public License v1.0
 *   and Apache License v2.0 which accompanies this distribution.
 *   The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
 *   and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php.
 *
 *   You may elect to redistribute this code under either of these licenses.
 *
 *   Contributors:
 *
 *   <NAME>
 */
package org.jnosql.artemis.reflection;

import org.jnosql.artemis.DynamicQueryException;
import org.jnosql.artemis.Page;
import org.jnosql.artemis.Pagination;

import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.TreeSet;
import java.util.stream.Stream;

/**
 * An implementation of {@link DynamicExecutorQueryConverter} that uses pagination at it.
 */
final class PaginationDynamicExecutorQueryConverter implements DynamicExecutorQueryConverter {


    @Override
    public <T> T toInstance(DynamicReturn<T> dynamic) {
        Optional<T> optional = dynamic.singleResultPagination();
        return optional.orElse(null);
    }

    @Override
    public <T> Optional<T> toOptional(DynamicReturn<T> dynamic) {
        return dynamic.singleResultPagination();
    }

    @Override
    public <T> List<T> toList(DynamicReturn<T> dynamic) {
        return dynamic.listPagination();
    }

    @Override
    public <T> Set<T> toSet(DynamicReturn<T> dynamic) {
        return new HashSet<>(dynamic.listPagination());
    }

    @Override
    public <T> LinkedList<T> toLinkedList(DynamicReturn<T> dynamic) {
        return new LinkedList<>(dynamic.listPagination());
    }

    @Override
    public <T> Stream<T> toStream(DynamicReturn<T> dynamic) {
        return dynamic.listPagination().stream();
    }

    @Override
    public <T> TreeSet<T> toTreeSet(DynamicReturn<T> dynamic) {
        return new TreeSet<>(dynamic.listPagination());
    }

    @Override
    public <T> Object toDefault(DynamicReturn<T> dynamic) {
        return dynamic.listPagination();
    }

    @Override
    public <T> Page<T> toPage(DynamicReturn<T> dynamic) {
        return dynamic.getPage();
    }
}
<commit_msg>removes unnecessary imports<commit_after>/*
 *  Copyright (c) 2019 <NAME> and others
 *   All rights reserved. This program and the accompanying materials
 *   are made available under the terms of the Eclipse Public License v1.0
 *   and Apache License v2.0 which accompanies this distribution.
 *   The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
 *   and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php.
 *
 *   You may elect to redistribute this code under either of these licenses.
 *
 *   Contributors:
 *
 *   <NAME>
 */
package org.jnosql.artemis.reflection;

import org.jnosql.artemis.Page;

import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.TreeSet;
import java.util.stream.Stream;

/**
 * An implementation of {@link DynamicExecutorQueryConverter} that uses pagination at it.
 */
final class PaginationDynamicExecutorQueryConverter implements DynamicExecutorQueryConverter {


    @Override
    public <T> T toInstance(DynamicReturn<T> dynamic) {
        Optional<T> optional = dynamic.singleResultPagination();
        return optional.orElse(null);
    }

    @Override
    public <T> Optional<T> toOptional(DynamicReturn<T> dynamic) {
        return dynamic.singleResultPagination();
    }

    @Override
    public <T> List<T> toList(DynamicReturn<T> dynamic) {
        return dynamic.listPagination();
    }

    @Override
    public <T> Set<T> toSet(DynamicReturn<T> dynamic) {
        return new HashSet<>(dynamic.listPagination());
    }

    @Override
    public <T> LinkedList<T> toLinkedList(DynamicReturn<T> dynamic) {
        return new LinkedList<>(dynamic.listPagination());
    }

    @Override
    public <T> Stream<T> toStream(DynamicReturn<T> dynamic) {
        return dynamic.listPagination().stream();
    }

    @Override
    public <T> TreeSet<T> toTreeSet(DynamicReturn<T> dynamic) {
        return new TreeSet<>(dynamic.listPagination());
    }

    @Override
    public <T> Object toDefault(DynamicReturn<T> dynamic) {
        return dynamic.listPagination();
    }

    @Override
    public <T> Page<T> toPage(DynamicReturn<T> dynamic) {
        return dynamic.getPage();
    }
}

{'fraction_non_alphanumeric': 0.1075037626316921, 'fraction_numerical': 0.006020210707374758, 'mean_word_length': 3.52089407191448, 'pattern_counts': {'":': 0, '<': 65, '<?xml version=': 0, '>': 65, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, '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': '5533581', 'n_tokens_mistral': 1395, 'n_tokens_neox': 1367, 'n_words': 362}