src/java.base/share/classes/java/util/ImmutableCollections.java
changeset 50698 c1f7ece09b84
parent 49919 96d4658eb7f2
child 50809 6ff774d73176
equal deleted inserted replaced
50697:3ef0862bbb3d 50698:c1f7ece09b84
    80         @Override public boolean removeIf(Predicate<? super E> filter) { throw uoe(); }
    80         @Override public boolean removeIf(Predicate<? super E> filter) { throw uoe(); }
    81         @Override public boolean retainAll(Collection<?> c) { throw uoe(); }
    81         @Override public boolean retainAll(Collection<?> c) { throw uoe(); }
    82     }
    82     }
    83 
    83 
    84     // ---------- List Implementations ----------
    84     // ---------- List Implementations ----------
       
    85 
       
    86     // make a copy, short-circuiting based on implementation class
       
    87     @SuppressWarnings("unchecked")
       
    88     static <E> List<E> listCopy(Collection<? extends E> coll) {
       
    89         if (coll instanceof AbstractImmutableList && coll.getClass() != SubList.class) {
       
    90             return (List<E>)coll;
       
    91         } else {
       
    92             return (List<E>)List.of(coll.toArray());
       
    93         }
       
    94     }
    85 
    95 
    86     @SuppressWarnings("unchecked")
    96     @SuppressWarnings("unchecked")
    87     static <E> List<E> emptyList() {
    97     static <E> List<E> emptyList() {
    88         return (List<E>) ListN.EMPTY_LIST;
    98         return (List<E>) ListN.EMPTY_LIST;
    89     }
    99     }