<commit_before>package com.github.rowanhill.boneidle;

import com.github.rowanhill.boneidle.exception.CannotInvokeLazyLoaderRuntimeException;

import java.lang.reflect.AnnotatedElement;
import java.lang.reflect.Method;

public class LoaderMethodResolver {
    /**
     * Finds the loader method for a given target method
     *
     * @param targetMethod The method for which to find the loader method
     * @return The loader method for the given targetMethod, or null if no loader method is defined.
     * @throws CannotInvokeLazyLoaderRuntimeException Thrown if the loader method is missing or parameterised
     */
    public Method getLoaderFor(Method targetMethod) {
        LazyLoadWith lazyLoadWith = getLoaderAnnotation(targetMethod);

        if (lazyLoadWith == null) {
            return null;
        }

        String loaderMethodName = lazyLoadWith.value();
        Method loaderMethod;
        try {
            loaderMethod = targetMethod.getDeclaringClass().getDeclaredMethod(loaderMethodName);
        } catch (NoSuchMethodException e) {
            throw CannotInvokeLazyLoaderRuntimeException.create(loaderMethodName, e);
        }
        return loaderMethod;
    }

    private LazyLoadWith getLoaderAnnotation(Method targetMethod) {
        if (targetMethod.isAnnotationPresent(ExcludeFromLazyLoading.class)) {
            return null;
        }

        LazyLoadWith annotation = getMethodAnnotation(targetMethod);
        if (annotation != null) {
            return annotation;
        }

        return getClassAnnotation(targetMethod);
    }

    private LazyLoadWith getMethodAnnotation(Method targetMethod) {
         return getAnnotation(targetMethod);
    }

    private LazyLoadWith getClassAnnotation(Method targetMethod) {
        Class<?> declaringClass = targetMethod.getDeclaringClass();
        return getAnnotation(declaringClass);
    }

    private LazyLoadWith getAnnotation(AnnotatedElement element) {
        return element.isAnnotationPresent(LazyLoadWith.class) ? element.getAnnotation(LazyLoadWith.class) : null;
    }
}
<commit_msg>Make LoaderMethodResolver package-private<commit_after>package com.github.rowanhill.boneidle;

import com.github.rowanhill.boneidle.exception.CannotInvokeLazyLoaderRuntimeException;

import java.lang.reflect.AnnotatedElement;
import java.lang.reflect.Method;

class LoaderMethodResolver {
    /**
     * Finds the loader method for a given target method
     *
     * @param targetMethod The method for which to find the loader method
     * @return The loader method for the given targetMethod, or null if no loader method is defined.
     * @throws CannotInvokeLazyLoaderRuntimeException Thrown if the loader method is missing or parameterised
     */
    Method getLoaderFor(Method targetMethod) {
        LazyLoadWith lazyLoadWith = getLoaderAnnotation(targetMethod);

        if (lazyLoadWith == null) {
            return null;
        }

        String loaderMethodName = lazyLoadWith.value();
        Method loaderMethod;
        try {
            loaderMethod = targetMethod.getDeclaringClass().getDeclaredMethod(loaderMethodName);
        } catch (NoSuchMethodException e) {
            throw CannotInvokeLazyLoaderRuntimeException.create(loaderMethodName, e);
        }
        return loaderMethod;
    }

    private LazyLoadWith getLoaderAnnotation(Method targetMethod) {
        if (targetMethod.isAnnotationPresent(ExcludeFromLazyLoading.class)) {
            return null;
        }

        LazyLoadWith annotation = getMethodAnnotation(targetMethod);
        if (annotation != null) {
            return annotation;
        }

        return getClassAnnotation(targetMethod);
    }

    private LazyLoadWith getMethodAnnotation(Method targetMethod) {
         return getAnnotation(targetMethod);
    }

    private LazyLoadWith getClassAnnotation(Method targetMethod) {
        Class<?> declaringClass = targetMethod.getDeclaringClass();
        return getAnnotation(declaringClass);
    }

    private LazyLoadWith getAnnotation(AnnotatedElement element) {
        return element.isAnnotationPresent(LazyLoadWith.class) ? element.getAnnotation(LazyLoadWith.class) : null;
    }
}

{'fraction_non_alphanumeric': 0.06862745098039216, 'fraction_numerical': 0.0, 'mean_word_length': 3.2510162601626016, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1119967', 'n_tokens_mistral': 1064, 'n_tokens_neox': 1043, 'n_words': 254}