RFR: 8221473: Configuration::reads can use Set.copyOf

Daniel Fuchs daniel.fuchs at oracle.com
Tue Mar 26 18:44:02 UTC 2019


Hi Peter,

On 26/03/2019 18:01, Peter Levart wrote:
> Would such method addition be worth it?

Here is the impl of Set.copyOf:

     static <E> Set<E> copyOf(Collection<? extends E> coll) {
         if (coll instanceof ImmutableCollections.AbstractImmutableSet) {
             return (Set<E>)coll;
         } else {
             return (Set<E>)Set.of(new HashSet<>(coll).toArray());
         }
     }

Best regards,

-- daniel


More information about the core-libs-dev mailing list