/** * Construct a new, empty instance of the {@code HttpHeaders} object. */ public HttpHeaders() { this(CollectionUtils.toMultiValueMap(new LinkedCaseInsensitiveMap<>(8, Locale.ENGLISH))); }
/** * Return an unmodifiable view of the specified multi-value map. * @param map the map for which an unmodifiable view is to be returned. * @return an unmodifiable view of the specified multi-value map. * @since 3.1 */ @SuppressWarnings("unchecked") public static <K, V> MultiValueMap<K, V> unmodifiableMultiValueMap(MultiValueMap<? extends K, ? extends V> map) { Assert.notNull(map, "'map' must not be null"); Map<K, List<V>> result = new LinkedHashMap<>(map.size()); map.forEach((key, value) -> { List<? extends V> values = Collections.unmodifiableList(value); result.put(key, (List<V>) values); }); Map<K, List<V>> unmodifiableMap = Collections.unmodifiableMap(result); return toMultiValueMap(unmodifiableMap); }
/** * Construct a new, empty instance of the {@code HttpHeaders} object. */ public HttpHeaders() { this(CollectionUtils.toMultiValueMap(new LinkedCaseInsensitiveMap<>(8, Locale.ENGLISH))); }
/** * Return an unmodifiable view of the specified multi-value map. * @param map the map for which an unmodifiable view is to be returned. * @return an unmodifiable view of the specified multi-value map. * @since 3.1 */ @SuppressWarnings("unchecked") public static <K, V> MultiValueMap<K, V> unmodifiableMultiValueMap(MultiValueMap<? extends K, ? extends V> map) { Assert.notNull(map, "'map' must not be null"); Map<K, List<V>> result = new LinkedHashMap<>(map.size()); map.forEach((key, value) -> { List<? extends V> values = Collections.unmodifiableList(value); result.put(key, (List<V>) values); }); Map<K, List<V>> unmodifiableMap = Collections.unmodifiableMap(result); return toMultiValueMap(unmodifiableMap); }
@Parameterized.Parameters(name = "headers [{0}]") public static Object[][] arguments() { return new Object[][] { {CollectionUtils.toMultiValueMap( new LinkedCaseInsensitiveMap<>(8, Locale.ENGLISH))}, {new NettyHeadersAdapter(new DefaultHttpHeaders())}, {new TomcatHeadersAdapter(new MimeHeaders())}, {new UndertowHeadersAdapter(new HeaderMap())}, {new JettyHeadersAdapter(new HttpFields())} }; }
/** * Returns an unmodifiable view of the specified multi-value map. * * @param map the map for which an unmodifiable view is to be returned. * @return an unmodifiable view of the specified multi-value map. */ public static <K,V> MultiValueMap<K,V> unmodifiableMultiValueMap(MultiValueMap<? extends K, ? extends V> map) { Assert.notNull(map, "'map' must not be null"); Map<K, List<V>> result = new LinkedHashMap<K, List<V>>(map.size()); for (Map.Entry<? extends K, ? extends List<? extends V>> entry : map.entrySet()) { List<V> values = Collections.unmodifiableList(entry.getValue()); result.put(entry.getKey(), values); } Map<K, List<V>> unmodifiableMap = Collections.unmodifiableMap(result); return toMultiValueMap(unmodifiableMap); }
/** * As multi value map. * * @param innerMap the inner map * @return the multi value map */ public static MultiValueMap asMultiValueMap(final Map innerMap) { return org.springframework.util.CollectionUtils.toMultiValueMap(innerMap); }
@Override public Supplier<MultiValueMap<K, V>> supplier() { return () -> CollectionUtils.toMultiValueMap(new HashMap<>()); }
/** * As multi value map. * * @param key the key * @param value the value * @return the multi value map */ public static MultiValueMap asMultiValueMap(final String key, final Object value) { return org.springframework.util.CollectionUtils.toMultiValueMap(wrap(key, value)); }
public static ResponseEntity<Object> missingParam(String paramName){ Map<String, List<String>> resultMap= new HashMap<>(); resultMap.put(ERROR_FIELD, Collections.singletonList(ERROR_INVALID_REQUEST_VALUE)); resultMap.put(ERROR_DESCRIPTION_FIELD, Collections.singletonList("Request parameter "+ paramName +" is missing. See https://tools.ietf.org/html/draft-ietf-oauth-token-exchange-08#section-2.1")); return ResponseEntity.badRequest().body(CollectionUtils.toMultiValueMap(resultMap)); }
/** * Construct a new, empty instance of the {@code HttpHeaders} object. */ public HttpHeaders() { this(CollectionUtils.toMultiValueMap( new LinkedCaseInsensitiveMap<>(8, Locale.ENGLISH))); }
public static ResponseEntity<Object> invalidParam(String message){ Map<String, List<String>> resultMap= new HashMap<>(); resultMap.put(ERROR_FIELD, Collections.singletonList(ERROR_INVALID_REQUEST_VALUE)); resultMap.put(ERROR_DESCRIPTION_FIELD, Collections.singletonList(message)); return ResponseEntity.badRequest().body(CollectionUtils.toMultiValueMap(resultMap)); } }
/** * Return an unmodifiable view of the specified multi-value map. * @param map the map for which an unmodifiable view is to be returned. * @return an unmodifiable view of the specified multi-value map. * @since 3.1 */ @SuppressWarnings("unchecked") public static <K, V> MultiValueMap<K, V> unmodifiableMultiValueMap(MultiValueMap<? extends K, ? extends V> map) { Assert.notNull(map, "'map' must not be null"); Map<K, List<V>> result = new LinkedHashMap<>(map.size()); map.forEach((key, value) -> { List<? extends V> values = Collections.unmodifiableList(value); result.put(key, (List<V>) values); }); Map<K, List<V>> unmodifiableMap = Collections.unmodifiableMap(result); return toMultiValueMap(unmodifiableMap); }
/** * Returns an unmodifiable view of the specified multi-value map. * * @param map the map for which an unmodifiable view is to be returned. * @return an unmodifiable view of the specified multi-value map. */ public static <K, V> MultiValueMap<K, V> unmodifiableMultiValueMap(MultiValueMap<? extends K, ? extends V> map) { Assert.notNull(map, "'map' must not be null"); Map<K, List<V>> result = new LinkedHashMap<K, List<V>>(map.size()); for (Map.Entry<? extends K, ? extends List<? extends V>> entry : map.entrySet()) { List<V> values = Collections.unmodifiableList(entry.getValue()); result.put(entry.getKey(), values); } Map<K, List<V>> unmodifiableMap = Collections.unmodifiableMap(result); return toMultiValueMap(unmodifiableMap); }
/** * Return an unmodifiable view of the specified multi-value map. * @param map the map for which an unmodifiable view is to be returned. * @return an unmodifiable view of the specified multi-value map. * @since 3.1 */ @SuppressWarnings("unchecked") public static <K, V> MultiValueMap<K, V> unmodifiableMultiValueMap(MultiValueMap<? extends K, ? extends V> map) { Assert.notNull(map, "'map' must not be null"); Map<K, List<V>> result = new LinkedHashMap<>(map.size()); map.forEach((key, value) -> { List<? extends V> values = Collections.unmodifiableList(value); result.put(key, (List<V>) values); }); Map<K, List<V>> unmodifiableMap = Collections.unmodifiableMap(result); return toMultiValueMap(unmodifiableMap); }
private static MultiValueMap<NameAndArgumentCount, Function> discoverDeclaredFunctions(Class<?> type) { MultiValueMap<NameAndArgumentCount, Function> map = CollectionUtils.toMultiValueMap(new HashMap<>()); ReflectionUtils.doWithMethods(type, // method -> map.add(NameAndArgumentCount.of(method), new Function(method, null)), // PublicMethodAndFieldFilter.STATIC); return CollectionUtils.unmodifiableMultiValueMap(map); }
/** * As multi value map. * * @param key1 the key 1 * @param value1 the value 1 * @param key2 the key 2 * @param value2 the value 2 * @return the multi value map */ public static MultiValueMap asMultiValueMap(final String key1, final Object value1, final String key2, final Object value2) { val wrap = (Map) wrap(key1, wrapList(value1), key2, wrapList(value2)); return org.springframework.util.CollectionUtils.toMultiValueMap(wrap); }
/** * Creates a new {@link BasicPersistentEntity} for the given {@link TypeInformation} and {@link Comparator}. The given * {@link Comparator} will be used to define the order of the {@link PersistentProperty} instances added to the * entity. * * @param information must not be {@literal null}. * @param comparator can be {@literal null}. */ public BasicPersistentEntity(TypeInformation<T> information, @Nullable Comparator<P> comparator) { Assert.notNull(information, "Information must not be null!"); this.information = information; this.properties = new ArrayList<>(); this.persistentPropertiesCache = new ArrayList<>(); this.comparator = comparator; this.constructor = PreferredConstructorDiscoverer.discover(this); this.associations = comparator == null ? new HashSet<>() : new TreeSet<>(new AssociationComparator<>(comparator)); this.propertyCache = new HashMap<>(16, 1f); this.annotationCache = new ConcurrentReferenceHashMap<>(16, ReferenceType.WEAK); this.propertyAnnotationCache = CollectionUtils .toMultiValueMap(new ConcurrentReferenceHashMap<>(16, ReferenceType.WEAK)); this.propertyAccessorFactory = BeanWrapperPropertyAccessorFactory.INSTANCE; this.typeAlias = Lazy.of(() -> getAliasFromAnnotation(getType())); this.isNewStrategy = Lazy.of(() -> Persistable.class.isAssignableFrom(information.getType()) // ? PersistableIsNewStrategy.INSTANCE : getFallbackIsNewStrategy()); this.isImmutable = Lazy.of(() -> isAnnotationPresent(Immutable.class)); this.requiresPropertyPopulation = Lazy.of(() -> !isImmutable() && properties.stream() // .anyMatch(it -> !(isConstructorArgument(it) || it.isTransient()))); }