<commit_before><commit_msg>Added a new IRegisterable type for supporting class based registries. <commit_after>package org.epoxide.commons.registry;

import org.epoxide.commons.reflection.ReflectionUtils;

/**
 * An implementation of IRegisterable, intended for registering class references. This is
 * intended for situations where you are using the registered Class to construct new Objects,
 * rather than registering a specific instance.
 */
public class RegisterableClass<T> extends Registerable<T> {

    /**
     * The contained class reference.
     */
    private final Class<? extends T> clazz;

    /**
     * Base constructor for a RegisterableClass.
     *
     * @param clazz The contained class.
     */
    public RegisterableClass (Class<? extends T> clazz) {

        this.clazz = clazz;
    }

    /**
     * Gets the contained class reference. The name of this method is to prevent overriding
     * {@link java.lang.Object#getClass()}.
     *
     * @return The contained class reference.
     */
    public Class<? extends T> getContainedClass () {

        return this.clazz;
    }

    /**
     * Attempts to construct the contained class using arbitrary arguments. Arguments only support primitives.
     * @param args The arguments used to construct the class.
     * @return The constructed instance. 
     */
    public T construct (Object... args) {

        return ReflectionUtils.constructClass(this.getContainedClass(), args);
    }
}
{'fraction_non_alphanumeric': 0.08526603001364257, 'fraction_numerical': 0.0, 'mean_word_length': 2.964864864864865, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, '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': '828764', 'n_tokens_mistral': 384, 'n_tokens_neox': 366, 'n_words': 140}