<commit_before>package permissions.dispatcher.processor;

import com.squareup.javapoet.ClassName;

import java.util.List;

import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.TypeElement;

import permissions.dispatcher.NeedsPermission;
import permissions.dispatcher.ShowsRationale;

import static permissions.dispatcher.processor.ConstantsProvider.CLASS_SUFFIX;
import static permissions.dispatcher.processor.Utils.findMethods;
import static permissions.dispatcher.processor.Utils.findShowsRationaleFromValue;
import static permissions.dispatcher.processor.Validator.checkClassName;
import static permissions.dispatcher.processor.Validator.checkDuplicatedPermission;
import static permissions.dispatcher.processor.Validator.checkDuplicatedRationale;
import static permissions.dispatcher.processor.Validator.checkNeedsPermissionSize;
import static permissions.dispatcher.processor.Validator.checkPrivateMethod;

public class RuntimePermissionsAnnotatedElement {

    private final String packageName;

    private final String className;

    private final ClassType classType;

    private final List<ExecutableElement> needsPermissionMethods;

    private final List<ExecutableElement> showsRationaleMethods;

    public RuntimePermissionsAnnotatedElement(TypeElement element) {
        String qualifiedName = element.getQualifiedName().toString();
        className = Utils.getClassName(qualifiedName);
        packageName = Utils.getPackageName(qualifiedName);
        checkClassName(className);
        classType = ClassType.getClassType(className);
        needsPermissionMethods = findMethods(element, NeedsPermission.class);
        checkNeedsPermissionSize(needsPermissionMethods);
        checkDuplicatedPermission(needsPermissionMethods);
        checkPrivateMethod(needsPermissionMethods);
        showsRationaleMethods = findMethods(element, ShowsRationale.class);
        checkDuplicatedRationale(showsRationaleMethods);
        checkPrivateMethod(showsRationaleMethods);
    }

    public String getPackageName() {
        return packageName;
    }

    public ClassName getClassName() {
        return ClassName.get(packageName, className);
    }

    public ClassType getClassType() {
        return classType;
    }

    public String getDispatchClassName() {
        return className + CLASS_SUFFIX;
    }<commit_msg>Do tiny refactor.<commit_after>package permissions.dispatcher.processor;

import com.squareup.javapoet.ClassName;

import java.util.List;

import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.TypeElement;

import permissions.dispatcher.NeedsPermission;
import permissions.dispatcher.ShowsRationale;

import static permissions.dispatcher.processor.ConstantsProvider.CLASS_SUFFIX;
import static permissions.dispatcher.processor.Utils.findMethods;
import static permissions.dispatcher.processor.Utils.findShowsRationaleFromValue;
import static permissions.dispatcher.processor.Validator.checkClassName;
import static permissions.dispatcher.processor.Validator.checkDuplicatedPermission;
import static permissions.dispatcher.processor.Validator.checkDuplicatedRationale;
import static permissions.dispatcher.processor.Validator.checkNeedsPermissionSize;
import static permissions.dispatcher.processor.Validator.checkPrivateMethod;

public class RuntimePermissionsAnnotatedElement {

    private final String packageName;

    private final String className;

    private final ClassType classType;

    private final List<ExecutableElement> needsPermissionMethods;

    private final List<ExecutableElement> showsRationaleMethods;

    public RuntimePermissionsAnnotatedElement(TypeElement element) {
        String qualifiedName = element.getQualifiedName().toString();
        className = Utils.getClassName(qualifiedName);
        validateClassName();
        packageName = Utils.getPackageName(qualifiedName);
        classType = ClassType.getClassType(className);
        needsPermissionMethods = findMethods(element, NeedsPermission.class);
        validateNeedsPermissionMethods();
        showsRationaleMethods = findMethods(element, ShowsRationale.class);
        validateShowRationaleMethods();
    }

    private void validateClassName() {
        checkClassName(className);
    }

    private void validateNeedsPermissionMethods() {
        checkNeedsPermissionSize(needsPermissionMethods);
        checkDuplicatedPermission(needsPermissionMethods);
        checkPrivateMethod(needsPermissionMethods);
    }

    private void validateShowRationaleMethods() {
        checkDuplicatedRationale(showsRationaleMethods);
        checkPrivateMethod(showsRationaleMethods);
    }

    public String getPackageName() {
        return packageName;
    }

    public ClassName getClassName() {
        return ClassName.get(packageName, className);
    }

    public ClassType getClassType() {
        return classType;
    }

    public String getDispatchClassName() {
        return className + CLASS_SUFFIX;
    }
{'fraction_non_alphanumeric': 0.06867638251147934, 'fraction_numerical': 0.0, 'mean_word_length': 4.914994096812278, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '6547235', 'n_tokens_mistral': 1211, 'n_tokens_neox': 1200, 'n_words': 228}