Walks by map's nodes and extracts optional value of type T.
@param <T> value type
@param clazz type of value
@param map subject
@param pathString dot separated string with nodes of nested maps
@return optional value of type T
193002
public static <T> Optional<T> dotGet(final Map map, final Class<T> clazz, final String pathString) {
        if (pathString == null || pathString.isEmpty()) {
            throw new IllegalArgumentException(PATH_MUST_BE_SPECIFIED);
        }
        if (!pathString.contains(SEPARATOR)) {
            return Optional.ofNullable((T) map.get(pathString));
        }
        final Object[] path = pathString.split(SEPARATOR_REGEX);
        return MapApi.get(map, clazz, path);
    }
758650
public static <T> Optional<T> getObjectOptional(Config config, String path, Class<T> clazz) {
        return Optional.ofNullable(getObject(config, path, clazz));
    }
522973
public static <T> Optional<T> getNullableOptional(final List list, final Class<T> clazz, final Integer... path) {
        return getNullable(list, Optional.class, path);
    }
937923
public static Map<TypeVariable, Type> getTypeVariableMap(Class<?> clazz) {
		Map<TypeVariable, Type> typeVariableMap = typeVariableCache.get(clazz);

		if (typeVariableMap == null) {
			typeVariableMap = new HashMap<TypeVariable, Type>();

			// interfaces
			extractTypeVariablesFromGenericInterfaces(clazz.getGenericInterfaces(), typeVariableMap);

			try {
				// super class
				Class<?> type = clazz;
				while (type.getSuperclass() != null && !Object.class.equals(type.getSuperclass())) {
					Type genericType = type.getGenericSuperclass();
					if (genericType instanceof ParameterizedType) {
						ParameterizedType pt = (ParameterizedType) genericType;
						populateTypeMapFromParameterizedType(pt, typeVariableMap);
					}
					extractTypeVariablesFromGenericInterfaces(type.getSuperclass().getGenericInterfaces(), typeVariableMap);
					type = type.getSuperclass();
				}
			}
			catch (MalformedParameterizedTypeException ex) {
				// from getGenericSuperclass() - ignore and continue with member class check
			}

			try {
				// enclosing class
				Class<?> type = clazz;
				while (type.isMemberClass()) {
					Type genericType = type.getGenericSuperclass();
					if (genericType instanceof ParameterizedType) {
						ParameterizedType pt = (ParameterizedType) genericType;
						populateTypeMapFromParameterizedType(pt, typeVariableMap);
					}
					type = type.getEnclosingClass();
				}
			}
			catch (MalformedParameterizedTypeException ex) {
				// from getGenericSuperclass() - ignore and preserve previously accumulated type variables
			}

			typeVariableCache.put(clazz, typeVariableMap);
		}

		return typeVariableMap;
	}
732041
public static void extractPlaceholders(ClassNode node, Map<GenericsTypeName, GenericsType> map) {
        if (node == null) return;

        if (node.isArray()) {
            extractPlaceholders(node.getComponentType(), map);
            return;
        }

        if (!node.isUsingGenerics() || !node.isRedirectNode()) return;
        GenericsType[] parameterized = node.getGenericsTypes();
        if (parameterized == null || parameterized.length == 0) return;
        GenericsType[] redirectGenericsTypes = node.redirect().getGenericsTypes();
        if (redirectGenericsTypes == null ||
                (node.isGenericsPlaceHolder() && redirectGenericsTypes.length != parameterized.length) /* GROOVY-8609 */ ) {
            redirectGenericsTypes = parameterized;
        }
        if (redirectGenericsTypes.length != parameterized.length) {
            throw new GroovyBugError("Expected earlier checking to detect generics parameter arity mismatch" +
                    "\nExpected: " + node.getName() + toGenericTypesString(redirectGenericsTypes) +
                    "\nSupplied: " + node.getName() + toGenericTypesString(parameterized));
        }

        List<GenericsType> valueList = new LinkedList<>();
        for (int i = 0; i < redirectGenericsTypes.length; i++) {
            GenericsType redirectType = redirectGenericsTypes[i];
            if (redirectType.isPlaceholder()) {
                GenericsTypeName name = new GenericsTypeName(redirectType.getName());
                if (!map.containsKey(name)) {
                    GenericsType value = parameterized[i];
                    map.put(name, value);

                    valueList.add(value);
                }
            }
        }

        for (GenericsType value : valueList) {
            if (value.isWildcard()) {
                ClassNode lowerBound = value.getLowerBound();
                if (lowerBound != null) {
                    extractPlaceholders(lowerBound, map);
                }
                ClassNode[] upperBounds = value.getUpperBounds();
                if (upperBounds != null) {
                    for (ClassNode upperBound : upperBounds) {
                        extractPlaceholders(upperBound, map);
                    }
                }
            } else if (!value.isPlaceholder()) {
                extractPlaceholders(value.getType(), map);
            }
        }
    }
1247176
public static String getNullableString(final Map map, final Object... path) {
        return getNullable(map, String.class, path);
    }
1184723
public void parseMember(Map map) {
    String key = T.getString();
    check(TokenType.STRING, "a string");
    check(TokenType.COLON, ":");
    Object val = parseValue();
    map.put(key, val);
  }
1120493
static <T extends ValueMap> T createValueMap(Map map, Class<T> clazz) {
    try {
      Constructor<T> constructor = clazz.getDeclaredConstructor(Map.class);
      constructor.setAccessible(true);
      return constructor.newInstance(map);
    } catch (Exception e) {
      throw new AssertionError(
          "Could not create instance of " + clazz.getCanonicalName() + ".\n" + e);
    }
  }
1312575
public static <T> Optional<Optional<T>> dotGetOptional(
            final Map map, final String pathString, final Class<T> clazz
    ) {
        return dotGet(map, Optional.class, pathString).map(opt -> (Optional<T>) opt);
    }
173793
@SuppressWarnings("unchecked")
    protected static <T extends ExpandableStringEnum<T>> Collection<T> values(Class<T> clazz) {
        // Make a copy of all values
        Collection<? extends ExpandableStringEnum<?>> values = new ArrayList<>(valuesByName.values());

        Collection<T> list = new HashSet<T>();
        for (ExpandableStringEnum<?> value : values) {
            if (value.getClass().isAssignableFrom(clazz)) {
                list.add((T) value);
            }
        }

        return list;
    }
1006903
public static <T> Optional<List<T>> getList(final Map map, final Class<T> clazz, final Object... path) {
        return get(map, List.class, path).map(c -> (List<T>) c);
    }
1171790
public static <K,V> Optional<V> getOpt(Map<K,V> map, K key) {
        return Optional.ofNullable(map.get(key));
    }
1278401
@CheckForNull
    public <T extends NodeProperty> T getNodeProperty(Class<T> clazz)
    {
        for (NodeProperty p: getNodeProperties()) {
            if (clazz.isInstance(p)) {
                return clazz.cast(p);
            }
        }
        return null;      
    }
38398
public static <A, B> Map<A, B> getNullableMap(final Map map, final Object... path) {
        return getNullable(map, Map.class, path);
    }
990040
private static String getValue(Map<String, String> map, String keyName) {
    String value = map.get(keyName);
    return value == null ? "-" : value;
  }
547962
@SuppressWarnings("unchecked")
    public static <K, V> K[] mapKeyToArray(Map<K, V> map, Class<K> clazz) {
        if (Checker.isNotEmpty(map)) {
            K[] array = (K[]) Array.newInstance(clazz, map.size());
            int i = 0;
            for (K k : map.keySet()) {
                array[i++] = k;
            }
            return array;
        }
        return null;
    }
890603
protected OptionalThing<PathParamArgs> preparePathParamArgs(List<Class<?>> pathParamTypeList,
            Map<Integer, Class<?>> optionalGenericTypeMap) {
        final PathParamArgs args = !pathParamTypeList.isEmpty() ? newPathParamArgs(pathParamTypeList, optionalGenericTypeMap) : null;
        return OptionalThing.ofNullable(args, () -> throwPathParamArgsNotFoundException());
    }