<commit_before>package com.forter.contracts.reflection;

import com.forter.contracts.IContractsBolt;
import com.google.common.base.Function;
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.common.reflect.TypeToken;
import org.hibernate.validator.valuehandling.UnwrapValidatedValue;

import javax.validation.constraints.NotNull;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.lang.reflect.TypeVariable;
import java.util.Arrays;
import java.util.Collection;
import java.util.Set;

/**
 * Reflects on types and annotations of {@link com.forter.contracts.IContractsBolt} implementations.
 */
public class ContractsBoltReflector<TInput, TOutput, TContractsBolt extends IContractsBolt<TInput, TOutput>> {

    private final TContractsBolt bolt;
    public enum EXECUTE_RETURN_TYPE {NOT_NULL_CONTRACT, OPTIONAL_CONTRACT, COLLECTION_CONTRACTS}
    private EXECUTE_RETURN_TYPE executeReturnType;
    private Class<TInput> inputClass;
    private Class<TOutput> outputClass;

    public ContractsBoltReflector(TContractsBolt bolt) {
        this.bolt = bolt;
        reflectOnDelegate();
    }

    public EXECUTE_RETURN_TYPE getExecuteReturnType() {
        return executeReturnType;
    }

    public Class<TInput> getInputClass() {
        return inputClass;
    }

    private void reflectOnDelegate() {
        TypeToken<? extends IContractsBolt> boltTypeToken = TypeToken.of(bolt.getClass());
        TypeVariable<Class<IContractsBolt>>[] typeParameters = IContractsBolt.class.getTypeParameters();

        TypeToken<?> inputTypeToken = boltTypeToken.resolveType(typeParameters[0]);
        inputClass = (Class<TInput>) inputTypeToken.getRawType();
        checkAnnotations(inputClass);

        TypeToken<?> outputTypeToken = boltTypeToken.resolveType(typeParameters[1]);
        Class<?> outputRawType = outputTypeToken.getRawType();
        checkAnnotations(outputRawType);<commit_msg>added getter for outputType in ContractsBoltReflector<commit_after>package com.forter.contracts.reflection;

import com.forter.contracts.IContractsBolt;
import com.google.common.base.Function;
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.common.reflect.TypeToken;
import org.hibernate.validator.valuehandling.UnwrapValidatedValue;

import javax.validation.constraints.NotNull;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.lang.reflect.TypeVariable;
import java.util.Arrays;
import java.util.Collection;
import java.util.Set;

/**
 * Reflects on types and annotations of {@link com.forter.contracts.IContractsBolt} implementations.
 */
public class ContractsBoltReflector<TInput, TOutput, TContractsBolt extends IContractsBolt<TInput, TOutput>> {

    private final TContractsBolt bolt;
    public enum EXECUTE_RETURN_TYPE {NOT_NULL_CONTRACT, OPTIONAL_CONTRACT, COLLECTION_CONTRACTS}
    private EXECUTE_RETURN_TYPE executeReturnType;
    private Class<TInput> inputClass;
    private Class<TOutput> outputClass;

    public ContractsBoltReflector(TContractsBolt bolt) {
        this.bolt = bolt;
        reflectOnDelegate();
    }

    public EXECUTE_RETURN_TYPE getExecuteReturnType() {
        return executeReturnType;
    }

    public Class<TInput> getInputClass() {
        return inputClass;
    }

    public Class<TOutput> getOutputClass() {
        return outputClass;
    }

    private void reflectOnDelegate() {
        TypeToken<? extends IContractsBolt> boltTypeToken = TypeToken.of(bolt.getClass());
        TypeVariable<Class<IContractsBolt>>[] typeParameters = IContractsBolt.class.getTypeParameters();

        TypeToken<?> inputTypeToken = boltTypeToken.resolveType(typeParameters[0]);
        inputClass = (Class<TInput>) inputTypeToken.getRawType();
        checkAnnotations(inputClass);

        TypeToken<?> outputTypeToken = boltTypeToken.resolveType(typeParameters[1]);
        Class<?> outputRawType = outputTypeToken.getRawType();
        checkAnnotations(outputRawType);
{'fraction_non_alphanumeric': 0.0933239304184297, 'fraction_numerical': 0.0009402914903620122, 'mean_word_length': 4.84478021978022, 'pattern_counts': {'":': 0, '<': 28, '<?xml version=': 0, '>': 28, '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': '5532745', 'n_tokens_mistral': 1246, 'n_tokens_neox': 1235, 'n_words': 227}