<commit_before>/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package minetweaker.runtime.providers;

import minetweaker.MineTweakerAPI;
import minetweaker.runtime.IScriptIterator;
import minetweaker.runtime.IScriptProvider;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 * @author Stan
 */
public class ScriptProviderDirectory implements IScriptProvider {
    private final File directory;

    public ScriptProviderDirectory(File directory) {
        if (directory == null)
            throw new IllegalArgumentException("directory cannot be null");

        this.directory = directory;
    }

    @Override
    public Iterator<IScriptIterator> getScripts() {
        List<IScriptIterator> scripts = new ArrayList<IScriptIterator>();
        if (directory.exists()) {
            for (File file : directory.listFiles()) {
                if (file.isDirectory()) {
                    scripts.add(new ScriptIteratorDirectory(file));
                } else if (file.getName().endsWith(".zs")) {
                    scripts.add(new ScriptIteratorSingle(file));
                } else if (file.getName().endsWith(".zip")) {
                    try {
                        scripts.add(new ScriptIteratorZip(file));
                    } catch (IOException ex) {
                        MineTweakerAPI.logError("Could not load " + file.getName() + ": " + ex.getMessage());
                    }
                }
            }
        }
        scripts.sort((sc, sc1) -> sc.getName().compareTo(sc1.getName()));
        return scripts.iterator();
    }
}<commit_msg>removed lambda<commit_after>/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package minetweaker.runtime.providers;

import minetweaker.MineTweakerAPI;
import minetweaker.runtime.IScriptIterator;
import minetweaker.runtime.IScriptProvider;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;

/**
 * @author Stan
 */
public class ScriptProviderDirectory implements IScriptProvider {
    private final File directory;

    public ScriptProviderDirectory(File directory) {
        if (directory == null)
            throw new IllegalArgumentException("directory cannot be null");

        this.directory = directory;
    }

    @Override
    public Iterator<IScriptIterator> getScripts() {
        List<IScriptIterator> scripts = new ArrayList<IScriptIterator>();
        if (directory.exists()) {
            for (File file : directory.listFiles()) {
                if (file.isDirectory()) {
                    scripts.add(new ScriptIteratorDirectory(file));
                } else if (file.getName().endsWith(".zs")) {
                    scripts.add(new ScriptIteratorSingle(file));
                } else if (file.getName().endsWith(".zip")) {
                    try {
                        scripts.add(new ScriptIteratorZip(file));
                    } catch (IOException ex) {
                        MineTweakerAPI.logError("Could not load " + file.getName() + ": " + ex.getMessage());
                    }
                }
            }
        }
        scripts.sort(new Comparator<IScriptIterator>() {
            @Override
            public int compare(IScriptIterator sc, IScriptIterator sc1) {
                return sc.getName().compareTo(sc1.getName());
            }
        });
        return scripts.iterator();
    }
}
{'fraction_non_alphanumeric': 0.1056953642384106, 'fraction_numerical': 0.0010596026490066225, 'mean_word_length': 2.289198606271777, 'pattern_counts': {'":': 2, '<': 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': '4744795', 'n_tokens_mistral': 961, 'n_tokens_neox': 936, 'n_words': 237}