code: public static LinkedHashMap<String, Type> resolveGenerics(final Type type,
                                                                final Map<String, Type> generics) {
          Type actual = type;
          if (type instanceof ParameterizedType) {
              // if parameterized type is not correct (contain only raw type without type arguments
              // (possible for instance types) then this call could unwrap it to pure class
              actual = GenericsUtils.resolveTypeVariables(type, generics);
          }
          final LinkedHashMap<String, Type> res;
          if (actual instanceof ParameterizedType) {
              final ParameterizedType actualType = (ParameterizedType) actual;
              final Type[] genericTypes = actualType.getActualTypeArguments();
              final Class target = (Class) actualType.getRawType();
              final TypeVariable[] genericNames = target.getTypeParameters();
  
              // inner class can use outer class generics
              res = fillOuterGenerics(actual, new LinkedHashMap<String, Type>(), null);
  
              final int cnt = genericNames.length;
              for (int i = 0; i < cnt; i++) {
                  res.put(genericNames[i].getName(), genericTypes[i]);
              }
          } else {
              res = resolveRawGenerics(GenericsUtils.resolveClass(actual, generics));
          }
          return res;
      }
docs: Resolve declared generics for type (actually declared generics in context of some type).
  If provided class is inner class - resolves outer class generics as upper bound
  <p>
  If type is not {@link ParameterizedType} and so does not contains actual generics info, resolve
  generics from type declaration ({@link #resolveRawGenerics(Class)}),
  <p>
  NOTE: for {@link WildcardType} returned map will contain only first upper bound type generics, resolved
  by upper bound (because in many cases it would be impossible to build not contradicting generics map for
  wildcard due to same generic names in different types).
  
  @param type     type to resolve generics for
  @param generics generics of context class
  @return resolved generics of parameterized type or empty map