<commit_before>package org.adligo.tests4j.run.discovery;

import java.lang.annotation.Annotation;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

import org.adligo.tests4j.models.shared.common.I_TrialType;
import org.adligo.tests4j.models.shared.common.TrialType;
import org.adligo.tests4j.models.shared.i18n.I_Tests4J_AnnotationErrors;
import org.adligo.tests4j.models.shared.system.Tests4J_Constants;
import org.adligo.tests4j.models.shared.trials.I_AbstractTrial;
import org.adligo.tests4j.models.shared.trials.TrialTypeAnnotation;

public class TrialTypeFinder {
	private static final String CLASS_NAME = TrialTypeAnnotation.class.getName();
	
	public static I_TrialType getTypeInternal(Class<? extends I_AbstractTrial> trialClass) 
	throws IllegalArgumentException {
		Object annotation = getTrialTypeAnnotation(trialClass);
		
		if (annotation == null) {
			I_Tests4J_AnnotationErrors messages = Tests4J_Constants.CONSTANTS.getAnnotationErrors();
			String resultFailureMessage = messages.getMissingTypeAnnotationPre() + 
						trialClass.getName() + 
					messages.getMissingTypeAnnotationPost();
			throw new IllegalArgumentException(resultFailureMessage);
		}
		
		Method typeM;
		try {
			typeM = annotation.getClass().getMethod("type", new Class[] {});
			Object result = typeM.invoke(annotation, new Object[] {});
			I_TrialType typeEnum = TrialType.get((Integer) result);
			return typeEnum;
		} catch (NoSuchMethodException | SecurityException | IllegalAccessException | InvocationTargetException e) {
			throw new IllegalArgumentException(e);
		}
		
	}
	
	private static Object getTrialTypeAnnotation(Class<?> trialClass) {
		Annotation [] annos = trialClass.getAnnotations();
		for (int i = 0; i < annos.length; i++) {
			Annotation ann = annos[0];
			String annonName = ann.annotationType().getName();
			if (CLASS_NAME.equals(annonName)) {
				return ann;
			}
		}
		Class<?> checking = trialClass.getSuperclass();
		if (checking == null) {
			return null;
		}
		return getTrialTypeAnnotation(checking);
	}
}<commit_msg>removed old code<commit_after>package org.adligo.tests4j.run.discovery;

import org.adligo.tests4j.models.shared.common.I_TrialType;
import org.adligo.tests4j.models.shared.common.TrialType;
import org.adligo.tests4j.models.shared.i18n.I_Tests4J_AnnotationErrors;
import org.adligo.tests4j.models.shared.system.Tests4J_Constants;
import org.adligo.tests4j.models.shared.trials.I_AbstractTrial;
import org.adligo.tests4j.models.shared.trials.TrialTypeAnnotation;

public class TrialTypeFinder {
	public static I_TrialType getTypeInternal(Class<? extends I_AbstractTrial> trialClass) 
	throws IllegalArgumentException {
		TrialTypeAnnotation type = trialClass.getAnnotation(TrialTypeAnnotation.class);
		
		if (type == null)  {
			Class<?> checking = trialClass.getSuperclass();
			while (!Object.class.equals(checking)) {
				type = checking.getAnnotation(TrialTypeAnnotation.class);
				if (type != null) {
					break;
				}
				checking = checking.getSuperclass();
			}
		}
		
		if (type == null) {
			I_Tests4J_AnnotationErrors messages = Tests4J_Constants.CONSTANTS.getAnnotationErrors();
			String resultFailureMessage = messages.getMissingTypeAnnotationPre() + 
						trialClass.getName() + 
					messages.getMissingTypeAnnotationPost();
			throw new IllegalArgumentException(resultFailureMessage);
		}
		I_TrialType typeEnum = TrialType.get(type.type());
		return typeEnum;
	}
}
{'fraction_non_alphanumeric': 0.10433526011560694, 'fraction_numerical': 0.008092485549132947, 'mean_word_length': 5.247292418772563, 'pattern_counts': {'":': 0, '<': 9, '<?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': '6957996', 'n_tokens_mistral': 1188, 'n_tokens_neox': 1037, 'n_words': 183}