Get actual type by the type map.

@param map
@param type
@return The actual type. Return itself if it's already the most explicit type.
552768
private static Type getActualType(Map<TypeVariable<?>, Type> map, Type type) {
    return TypeVisitor.of(type, b -> b
        .onClass(c -> c)
        .onTypeVariable(tv -> map.containsKey(tv) ? getActualType(map, map.get(tv)) : tv)
        .onParameterizedType(pt -> TypeVisitor.of(pt.getRawType(), bb -> bb
            .onClass(c -> createParameterizedType(c, pt.getOwnerType(),
                Arrays.stream(pt.getActualTypeArguments()).map(t -> getActualType(map, t)).toArray(Type[]::new)))
            .result()))
        .onWildcardType(wt -> createWildcardType(
            Arrays.stream(wt.getUpperBounds()).map(t -> getActualType(map, t)).toArray(Type[]::new),
            Arrays.stream(wt.getLowerBounds()).map(t -> getActualType(map, t)).toArray(Type[]::new)))
        .onGenericArrayType(gat -> createGenericArrayType(getActualType(map, gat.getGenericComponentType())))
        .result(type));
  }
49816
private TypeVarToTypeMap mapTypes( TypeVarToTypeMap actualParamByVarName, IType... types )
  {
    for( int i = 0; i < types.length; i++ )
    {
      IType type = types[i];
      if( type instanceof ITypeVariableType )
      {
        actualParamByVarName.put( (ITypeVariableType)types[i], types[i] );
      }
      if( type instanceof ITypeVariableArrayType )
      {
        mapTypes( actualParamByVarName, type.getComponentType() );
      }
      if( type.isParameterizedType() )
      {
        IType[] parameters = type.getTypeParameters();
        mapTypes( actualParamByVarName, parameters );
      }
      if( type instanceof IFunctionType )
      {
        IFunctionType funType = (IFunctionType)type;
        mapTypes( actualParamByVarName, funType.getReturnType() );
        IType[] paramTypes = funType.getParameterTypes();
        for( IType paramType : paramTypes )
        {
          mapTypes( actualParamByVarName, paramType );
        }
      }
    }
    return actualParamByVarName;
  }
992358
function getMappingType(mapping) {
  if (is.array(mapping)) {
    return every(isMixed, mapping) ? 'mixed' : 'array';
  }
  if (is.object(mapping)) return 'map';
  return 'unknown';
}
268456
protected function typeMapReducer(array $map, $type)
    {
        if ($type instanceof ModifierInterface) {
            return $this->typeMapReducer($map, $type->getWrappedType());
        }

        if (!$type instanceof TypeInterface) {
            return $map;
        }

        if (!empty($map[$type->getName()])) {
            if ($type instanceof ObjectType || $type instanceof InterfaceType) {
                $type->setFields($map[$type->getName()]->getFields());
            }

            return $map;
        }

        $reducedMap = array_merge($map, [$type->getName() => $type]);
        if ($type instanceof InterfaceType || $type instanceof UnionType) {
            $reducedMap = array_reduce(
                $type->getPossibleTypes(), [$this, 'typeMapReducer'], $reducedMap
            );
        }

        if ($type instanceof ObjectType) {
            $reducedMap = array_reduce(
                $type->getInterfaces(), [$this, 'typeMapReducer'], $reducedMap
            );
        }

        if ($type instanceof ObjectType || $type instanceof InterfaceType) {
            foreach ($type->getFields() as $fieldName => $field) {
                $args = $field->getArguments();
                $reducedMap = array_reduce(array_map(function (FieldArgument $arg) {
                    return $arg->getType();
                }, $args), [$this, 'typeMapReducer'], $reducedMap);

                $reducedMap = $this->typeMapReducer($reducedMap, $field->getType());
            }
        }

        return $reducedMap;
    }
473070
public <T> T get(Class<T> stateType) {
		Map<Class<?>, Object> states = getStates();
		T value = getState( states, stateType );

		if ( value == null ) {
			throw new IllegalArgumentException( "Accessing state of type not enabled: " + stateType );
		}

		return value;
	}
519150
@SuppressWarnings("unchecked")
	@Override
	public Class<SortedMap<K, V>> getTypeClass() {
		return (Class<SortedMap<K, V>>) (Class<?>) SortedMap.class;
	}
1188892
static String actualTypeParametersString(TypeElement type) {
    List<? extends TypeParameterElement> typeParameters = type.getTypeParameters();
    if (typeParameters.isEmpty()) {
      return "";
    } else {
      return typeParameters
          .stream()
          .map(e -> e.getSimpleName().toString())
          .collect(joining(", ", "<", ">"));
    }
  }
577639
public <T> Map<String, T> findByTypeWithName(Class<T> type) {
        return BeanFactoryUtils.beansOfTypeIncludingAncestors(applicationContext, type);
    }
133157
@SuppressWarnings("unchecked")
  public <S, D> TypeMap<S, D> get(Class<S> sourceType, Class<D> destinationType, String typeMapName) {
    TypeMap<S, D> typeMap = (TypeMap<S, D>) typeMaps.get(TypePair.of(sourceType, destinationType, typeMapName));
    if (typeMap != null)
      return typeMap;

    for (TypePair<?, ?> typePair : getPrimitiveWrapperTypePairs(sourceType, destinationType, typeMapName)) {
      typeMap = (TypeMap<S, D>) typeMaps.get(typePair);
      if (typeMap != null)
        return typeMap;
    }

    return null;
  }
607670
public <T extends Mapping> T getMapping(MappingType type)
    {
        return (T) mappings.get(type);
    }
412074
public static Optional<Class> getPrimitiveType(String primitiveType) {
        return Optional.ofNullable(PRIMITIVE_TYPE_MAP.get(primitiveType));
    }
31219
public Optional<FieldTypes.Type> mapType(String typeName) {
        return Optional.ofNullable(TYPE_MAP.get(typeName));
    }
376623
def get_type(type_):
    
    if isinstance(type_, list):
        type_ = tuple(type_)

    for k, v in TYPE_MAP.iteritems():
        if k == type_:
            return v

    raise KeyError("Unknown type %r" % (type_,))
675749
@Nullable
	@Override
	public String getMapping(Class<?> type, Method method) {

		String key = key(type, method);

		return MAPPINGS.computeIfAbsent(key, __ -> delegate.getMapping(type, method));
	}
1360358
private static Class<?> getActualRawType(Type type) {
        Class<?> rawType;
        if (type instanceof ParameterizedType) {
            rawType = (Class<?>) ((ParameterizedType) type).getRawType();
        } else {
            rawType = (Class<?>) type;
        }
        return rawType;
    }
1052710
protected synchronized HierarchicalType getDataType(String type) {
        HierarchicalType dataType = typeInstances.get(type);
        //todo: are there still cases where type can be null?
        if (dataType == null) {
            dataType = createDataType(type);
            typeInstances.put(type, dataType);
        }
        return dataType;
    }
478226
public void setTypeMap(Map<TypeElement, org.revapi.java.model.TypeElement> typeMap) {
        this.typeMap = typeMap;
    }