src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/ImmutableHeaders.java
branchhttp-client-branch
changeset 56041 b4b5e09ef3cc
parent 55973 4d9b002587db
child 56054 352e845ae744
equal deleted inserted replaced
56040:f8eabb9a5c0f 56041:b4b5e09ef3cc
     1 /*
     1 /*
     2  * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
    45 
    45 
    46     public static ImmutableHeaders of(Map<String, List<String>> src) {
    46     public static ImmutableHeaders of(Map<String, List<String>> src) {
    47         return of(src, x -> true);
    47         return of(src, x -> true);
    48     }
    48     }
    49 
    49 
       
    50     public static ImmutableHeaders of(HttpHeaders headers) {
       
    51         return (headers instanceof ImmutableHeaders)
       
    52                 ? (ImmutableHeaders)headers
       
    53                 : of(headers.map());
       
    54     }
       
    55 
    50     public static ImmutableHeaders of(Map<String, List<String>> src,
    56     public static ImmutableHeaders of(Map<String, List<String>> src,
    51                                       Predicate<? super String> keyAllowed) {
    57                                       Predicate<? super String> keyAllowed) {
    52         requireNonNull(src, "src");
    58         requireNonNull(src, "src");
    53         requireNonNull(keyAllowed, "keyAllowed");
    59         requireNonNull(keyAllowed, "keyAllowed");
    54         return new ImmutableHeaders(src, keyAllowed);
    60         return new ImmutableHeaders(src, keyAllowed);