<commit_before>package org.sbrubbles.genericcons;

import java.lang.reflect.ParameterizedType;
import java.util.ArrayList;
import java.util.List;

import org.javaruntype.type.Type;
import org.javaruntype.type.Types;

/**
 * Captures and represents an open-ended list of types. This class isn't 
 * supposed to be instantiated; it is used to construct the list in the type
 * declaration, like below:
 * 
 * <pre>
 * Function&lt;?, ?&gt; f = new Function&lt;String, C&lt;Object, C&lt;Number, C&lt;String, Integer&gt;&gt;&gt;&gt;() {
 *   { // the no-arg constructor
 *     this.types = C.extractTypesFromSuperclass(this.getClass(), 1);
 *   }
 * };
 * </pre>
 * 
 * @author <NAME>
 * @param <First> The first type.
 * @param <Rest> The last type, or a C holding the rest of the types.
 */
public final class C<First, Rest> {
  // prevents instantiation
  private C() { /* empty block */ }
  
  /**
   * Searches the given base class' superclass for the list of types indexed by
   * {@code parameterIndex}.
   * 
   * @param baseClass the class whose generic superclass holds the list of 
   * type arguments. 
   * @param parameterIndex where in the given base class' generic superclass's 
   * type argument list is the desired list of types.
   * @return a list of the types found. 
   * @throws TypeParametersNotFoundException if no type parameters are found. 
   * @throws InvalidTypeException if there is a problem converting the standard
   * Java {@linkplain java.lang.reflect.Type type} to a {@linkplain Type fuller
   * representation}. <commit_msg>Javadocs and comments.<commit_after>package org.sbrubbles.genericcons;

import java.lang.reflect.ParameterizedType;
import java.util.ArrayList;
import java.util.List;

import org.javaruntype.type.Type;
import org.javaruntype.type.Types;

/**
 * Captures and represents an open-ended list of types. This class isn't 
 * supposed to be instantiated or subclassed; it's used to build the 
 * list in the type declaration, like below:
 * 
 * <pre>
 * Function&lt;?, ?&gt; f = new Function&lt;String, C&lt;Object, C&lt;Number, C&lt;String, Integer&gt;&gt;&gt;&gt;() {
 *   { // the no-arg constructor
 *     this.types = C.extractTypesFromSuperclass(this.getClass(), 1);
 *   }
 * };
 * </pre>
 * 
 * It was supposed to be {@code Cons} (hence the {@code C}), but using only
 * one letter kept type arguments (slightly) more readable.
 * 
 * @author <NAME>
 * @param <First> The first type.
 * @param <Rest> The last type, or a C holding the rest of the types.
 */
public final class C<First, Rest> {
  // preventing instantiation
  private C() { /* empty block */ }
  
  /**
   * Searches the given base class' superclass for the list of types indexed by
   * {@code parameterIndex}.
   * 
   * @param baseClass the class whose generic superclass holds the list of 
   * type arguments. 
   * @param parameterIndex where in the given base class' generic superclass' 
   * type argument list is the desired list of types.
   * @return a list of the types found. 
   * @throws TypeParametersNotFoundException if no type parameters are found. 
   * @throws InvalidTypeException if there is a problem converting the standard
   * Java {@linkplain java.lang.reflect.Type type} to a {@linkplain Type fuller
   * representation}. 
{'fraction_non_alphanumeric': 0.10897435897435898, 'fraction_numerical': 0.0006105006105006105, 'mean_word_length': 3.6154929577464787, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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': '7050986', 'n_tokens_mistral': 994, 'n_tokens_neox': 956, 'n_words': 367}