<commit_before>package com.strongjoshua.console;

import java.lang.reflect.Method;

import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.ObjectSet;
import com.badlogic.gdx.utils.ObjectSet.ObjectSetIterator;

class CommandCompleter {
	private ObjectSet<String> possibleCommands;
	private ObjectSetIterator<String> iterator;
	private String setString;

	public CommandCompleter() {
		possibleCommands = new ObjectSet<>();
		setString = "";
	}

	public void set(CommandExecutor ce, String s) {
		reset();
		setString = s.toLowerCase();
		Array<Method> methods = getAllMethodsOn(ce);
		for(Method m : methods) {
			String name = m.getName();
			if(name.toLowerCase().startsWith(setString))
				possibleCommands.add(name);
		}
		iterator = new ObjectSetIterator<>(possibleCommands);
	}

	public void reset() {
		possibleCommands.clear();
		setString = "";
		iterator = null;
	}

	public boolean isNew() {
		return possibleCommands.size == 0;
	}

	public boolean wasSetWith(String s) {
		return setString.equalsIgnoreCase(s);
	}

	public String next() {
		if(!iterator.hasNext)
			iterator.reset();
		return iterator.next();
	}<commit_msg>updated to not explode if we could not locate a method on the executor<commit_after>package com.strongjoshua.console;

import java.lang.reflect.Method;

import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.ObjectSet;
import com.badlogic.gdx.utils.ObjectSet.ObjectSetIterator;

class CommandCompleter {
	private ObjectSet<String> possibleCommands;
	private ObjectSetIterator<String> iterator;
	private String setString;

	public CommandCompleter() {
		possibleCommands = new ObjectSet<>();
		setString = "";
	}

	public void set(CommandExecutor ce, String s) {
		reset();
		setString = s.toLowerCase();
		Array<Method> methods = getAllMethodsOn(ce);
		for(Method m : methods) {
			String name = m.getName();
			if(name.toLowerCase().startsWith(setString))
				possibleCommands.add(name);
		}
		iterator = new ObjectSetIterator<>(possibleCommands);
	}

	public void reset() {
		possibleCommands.clear();
		setString = "";
		iterator = null;
	}

	public boolean isNew() {
		return possibleCommands.size == 0;
	}

	public boolean wasSetWith(String s) {
		return setString.equalsIgnoreCase(s);
	}

	public String next() {
		if(!iterator.hasNext) {
			iterator.reset();
			return setString;
		}
		return iterator.next();
	}
{'fraction_non_alphanumeric': 0.11984861227922625, 'fraction_numerical': 0.0008410428931875525, 'mean_word_length': 4.677804295942721, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '6809928', 'n_tokens_mistral': 802, 'n_tokens_neox': 753, 'n_words': 167}