code: public TypeMirror getDeclaredType(Collection<TypeMirror> values,
              TypeElement enclosing, TypeMirror target) {
          TypeElement targetElement = asTypeElement(target);
          List<? extends TypeParameterElement> targetTypeArgs = targetElement.getTypeParameters();
          if (targetTypeArgs.isEmpty()) {
              return target;
          }
  
          List<? extends TypeParameterElement> enclosingTypeArgs = enclosing.getTypeParameters();
          List<TypeMirror> targetTypeArgTypes = new ArrayList<>(targetTypeArgs.size());
  
          if (enclosingTypeArgs.isEmpty()) {
              for (TypeMirror te : values) {
                  List<? extends TypeMirror> typeArguments = ((DeclaredType)te).getTypeArguments();
                  if (typeArguments.size() >= targetTypeArgs.size()) {
                      for (int i = 0 ; i < targetTypeArgs.size(); i++) {
                          targetTypeArgTypes.add(typeArguments.get(i));
                      }
                      break;
                  }
              }
              // we found no matches in the hierarchy
              if (targetTypeArgTypes.isEmpty()) {
                  return target;
              }
          } else {
              if (targetTypeArgs.size() > enclosingTypeArgs.size()) {
                  return target;
              }
              for (int i = 0; i < targetTypeArgs.size(); i++) {
                  TypeParameterElement tpe = enclosingTypeArgs.get(i);
                  targetTypeArgTypes.add(tpe.asType());
              }
          }
          TypeMirror dt = typeUtils.getDeclaredType(targetElement,
                  targetTypeArgTypes.toArray(new TypeMirror[targetTypeArgTypes.size()]));
          return dt;
      }
docs: Finds the declaration of the enclosing's type parameter.
  
  @param values
  @param enclosing a TypeElement whose type arguments  we desire
  @param target the TypeMirror of the type as described by the enclosing
  @return