<commit_before>package com.google.code.morphia.ext.entityscanner;

import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

import org.reflections.Reflections;
import org.reflections.scanners.TypeAnnotationsScanner;
import org.reflections.scanners.TypesScanner;
import org.reflections.util.ClasspathHelper;
import org.reflections.util.ConfigurationBuilder;
import org.scannotation.ClasspathUrlFinder;

import com.google.code.morphia.Morphia;
import com.google.code.morphia.annotations.Entity;
import com.google.code.morphia.utils.Assert;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;

/**
 * @author <EMAIL>
 *
 */
public class EntityScanner {

	public EntityScanner(final Morphia m) {
		this(m, null);

	}

	public EntityScanner(final Morphia m, Predicate<String> predicate) {
		if (predicate == null) {
			predicate = Predicates.alwaysTrue();
		}
		Assert.parametersNotNull("m, predicate", m, predicate);
		final ConfigurationBuilder conf = new ConfigurationBuilder();
		conf.setScanners(new TypesScanner(), new TypeAnnotationsScanner());

		final Set<URL> s = new HashSet<URL>();
		s.addAll(ClasspathHelper.forClassLoader());
		s.addAll(Arrays.asList(ClasspathUrlFinder.findClassPaths()));
		conf.setUrls(new ArrayList<URL>(s));

		conf.filterInputsBy(predicate);

		final Reflections r = new Reflections(conf);

		final Set<Class<?>> entities = r.getTypesAnnotatedWith(Entity.class);
		for (final Class<?> c : entities) {
			m.map(c);<commit_msg>filter out jnilib entries to reduce false negative error logging<commit_after>package com.google.code.morphia.ext.entityscanner;

import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

import org.reflections.Reflections;
import org.reflections.scanners.TypeAnnotationsScanner;
import org.reflections.scanners.TypesScanner;
import org.reflections.util.ClasspathHelper;
import org.reflections.util.ConfigurationBuilder;
import org.scannotation.ClasspathUrlFinder;

import com.google.code.morphia.Morphia;
import com.google.code.morphia.annotations.Entity;
import com.google.code.morphia.utils.Assert;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;

/**
 * @author <EMAIL>
 *
 */
public class EntityScanner {

	public EntityScanner(final Morphia m) {
		this(m, null);

	}

	public EntityScanner(final Morphia m, Predicate<String> predicate) {
		if (predicate == null) {
			predicate = Predicates.alwaysTrue();
		}
		Assert.parametersNotNull("m, predicate", m, predicate);
		final ConfigurationBuilder conf = new ConfigurationBuilder();
		conf.setScanners(new TypesScanner(), new TypeAnnotationsScanner());

		final Set<URL> s = new HashSet<URL>();
		s.addAll(ClasspathHelper.forClassLoader());
		s.addAll(Arrays.asList(ClasspathUrlFinder.findClassPaths()));
    final Iterator<URL> iterator = s.iterator();
    while (iterator.hasNext()) {
      final URL url = iterator.next();
      if (url.getPath().endsWith("jnilib")) {
        iterator.remove();
      }
    }
    conf.setUrls(new ArrayList<URL>(s));

		conf.filterInputsBy(predicate);

		final Reflections r = new Reflections(conf);

		final Set<Class<?>> entities = r.getTypesAnnotatedWith(Entity.class);
		for (final Class<?> c : entities) {
			m.map(c);
{'fraction_non_alphanumeric': 0.12551561579257514, 'fraction_numerical': 0.0, 'mean_word_length': 5.298701298701299, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 20, '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': '5111679', 'n_tokens_mistral': 1120, 'n_tokens_neox': 1071, 'n_words': 211}