Advertisement
Guest User

Untitled

a guest
Mar 28th, 2020
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 7.77 KB | None | 0 0
  1. public interface List<E> extends Collection<E> {
  2.  
  3.     // [...]
  4.  
  5.     /**
  6.      * Returns an unmodifiable list containing zero elements.
  7.      *
  8.      * See <a href="#unmodifiable">Unmodifiable Lists</a> for details.
  9.      *
  10.      * @param <E> the {@code List}'s element type
  11.      * @return an empty {@code List}
  12.      *
  13.      * @since 9
  14.      */
  15.     @SuppressWarnings("unchecked")
  16.     static <E> List<E> of() {
  17.         return (List<E>) ImmutableCollections.ListN.EMPTY_LIST;
  18.     }
  19.  
  20.     /**
  21.      * Returns an unmodifiable list containing one element.
  22.      *
  23.      * See <a href="#unmodifiable">Unmodifiable Lists</a> for details.
  24.      *
  25.      * @param <E> the {@code List}'s element type
  26.      * @param e1 the single element
  27.      * @return a {@code List} containing the specified element
  28.      * @throws NullPointerException if the element is {@code null}
  29.      *
  30.      * @since 9
  31.      */
  32.     static <E> List<E> of(E e1) {
  33.         return new ImmutableCollections.List12<>(e1);
  34.     }
  35.  
  36.     /**
  37.      * Returns an unmodifiable list containing two elements.
  38.      *
  39.      * See <a href="#unmodifiable">Unmodifiable Lists</a> for details.
  40.      *
  41.      * @param <E> the {@code List}'s element type
  42.      * @param e1 the first element
  43.      * @param e2 the second element
  44.      * @return a {@code List} containing the specified elements
  45.      * @throws NullPointerException if an element is {@code null}
  46.      *
  47.      * @since 9
  48.      */
  49.     static <E> List<E> of(E e1, E e2) {
  50.         return new ImmutableCollections.List12<>(e1, e2);
  51.     }
  52.  
  53.     /**
  54.      * Returns an unmodifiable list containing three elements.
  55.      *
  56.      * See <a href="#unmodifiable">Unmodifiable Lists</a> for details.
  57.      *
  58.      * @param <E> the {@code List}'s element type
  59.      * @param e1 the first element
  60.      * @param e2 the second element
  61.      * @param e3 the third element
  62.      * @return a {@code List} containing the specified elements
  63.      * @throws NullPointerException if an element is {@code null}
  64.      *
  65.      * @since 9
  66.      */
  67.     static <E> List<E> of(E e1, E e2, E e3) {
  68.         return new ImmutableCollections.ListN<>(e1, e2, e3);
  69.     }
  70.  
  71.     /**
  72.      * Returns an unmodifiable list containing four elements.
  73.      *
  74.      * See <a href="#unmodifiable">Unmodifiable Lists</a> for details.
  75.      *
  76.      * @param <E> the {@code List}'s element type
  77.      * @param e1 the first element
  78.      * @param e2 the second element
  79.      * @param e3 the third element
  80.      * @param e4 the fourth element
  81.      * @return a {@code List} containing the specified elements
  82.      * @throws NullPointerException if an element is {@code null}
  83.      *
  84.      * @since 9
  85.      */
  86.     static <E> List<E> of(E e1, E e2, E e3, E e4) {
  87.         return new ImmutableCollections.ListN<>(e1, e2, e3, e4);
  88.     }
  89.  
  90.     /**
  91.      * Returns an unmodifiable list containing five elements.
  92.      *
  93.      * See <a href="#unmodifiable">Unmodifiable Lists</a> for details.
  94.      *
  95.      * @param <E> the {@code List}'s element type
  96.      * @param e1 the first element
  97.      * @param e2 the second element
  98.      * @param e3 the third element
  99.      * @param e4 the fourth element
  100.      * @param e5 the fifth element
  101.      * @return a {@code List} containing the specified elements
  102.      * @throws NullPointerException if an element is {@code null}
  103.      *
  104.      * @since 9
  105.      */
  106.     static <E> List<E> of(E e1, E e2, E e3, E e4, E e5) {
  107.         return new ImmutableCollections.ListN<>(e1, e2, e3, e4, e5);
  108.     }
  109.  
  110.     /**
  111.      * Returns an unmodifiable list containing six elements.
  112.      *
  113.      * See <a href="#unmodifiable">Unmodifiable Lists</a> for details.
  114.      *
  115.      * @param <E> the {@code List}'s element type
  116.      * @param e1 the first element
  117.      * @param e2 the second element
  118.      * @param e3 the third element
  119.      * @param e4 the fourth element
  120.      * @param e5 the fifth element
  121.      * @param e6 the sixth element
  122.      * @return a {@code List} containing the specified elements
  123.      * @throws NullPointerException if an element is {@code null}
  124.      *
  125.      * @since 9
  126.      */
  127.     static <E> List<E> of(E e1, E e2, E e3, E e4, E e5, E e6) {
  128.         return new ImmutableCollections.ListN<>(e1, e2, e3, e4, e5,
  129.                                                 e6);
  130.     }
  131.  
  132.     /**
  133.      * Returns an unmodifiable list containing seven elements.
  134.      *
  135.      * See <a href="#unmodifiable">Unmodifiable Lists</a> for details.
  136.      *
  137.      * @param <E> the {@code List}'s element type
  138.      * @param e1 the first element
  139.      * @param e2 the second element
  140.      * @param e3 the third element
  141.      * @param e4 the fourth element
  142.      * @param e5 the fifth element
  143.      * @param e6 the sixth element
  144.      * @param e7 the seventh element
  145.      * @return a {@code List} containing the specified elements
  146.      * @throws NullPointerException if an element is {@code null}
  147.      *
  148.      * @since 9
  149.      */
  150.     static <E> List<E> of(E e1, E e2, E e3, E e4, E e5, E e6, E e7) {
  151.         return new ImmutableCollections.ListN<>(e1, e2, e3, e4, e5,
  152.                                                 e6, e7);
  153.     }
  154.  
  155.     /**
  156.      * Returns an unmodifiable list containing eight elements.
  157.      *
  158.      * See <a href="#unmodifiable">Unmodifiable Lists</a> for details.
  159.      *
  160.      * @param <E> the {@code List}'s element type
  161.      * @param e1 the first element
  162.      * @param e2 the second element
  163.      * @param e3 the third element
  164.      * @param e4 the fourth element
  165.      * @param e5 the fifth element
  166.      * @param e6 the sixth element
  167.      * @param e7 the seventh element
  168.      * @param e8 the eighth element
  169.      * @return a {@code List} containing the specified elements
  170.      * @throws NullPointerException if an element is {@code null}
  171.      *
  172.      * @since 9
  173.      */
  174.     static <E> List<E> of(E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8) {
  175.         return new ImmutableCollections.ListN<>(e1, e2, e3, e4, e5,
  176.                                                 e6, e7, e8);
  177.     }
  178.  
  179.     /**
  180.      * Returns an unmodifiable list containing nine elements.
  181.      *
  182.      * See <a href="#unmodifiable">Unmodifiable Lists</a> for details.
  183.      *
  184.      * @param <E> the {@code List}'s element type
  185.      * @param e1 the first element
  186.      * @param e2 the second element
  187.      * @param e3 the third element
  188.      * @param e4 the fourth element
  189.      * @param e5 the fifth element
  190.      * @param e6 the sixth element
  191.      * @param e7 the seventh element
  192.      * @param e8 the eighth element
  193.      * @param e9 the ninth element
  194.      * @return a {@code List} containing the specified elements
  195.      * @throws NullPointerException if an element is {@code null}
  196.      *
  197.      * @since 9
  198.      */
  199.     static <E> List<E> of(E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8, E e9) {
  200.         return new ImmutableCollections.ListN<>(e1, e2, e3, e4, e5,
  201.                                                 e6, e7, e8, e9);
  202.     }
  203.  
  204.     /**
  205.      * Returns an unmodifiable list containing ten elements.
  206.      *
  207.      * See <a href="#unmodifiable">Unmodifiable Lists</a> for details.
  208.      *
  209.      * @param <E> the {@code List}'s element type
  210.      * @param e1 the first element
  211.      * @param e2 the second element
  212.      * @param e3 the third element
  213.      * @param e4 the fourth element
  214.      * @param e5 the fifth element
  215.      * @param e6 the sixth element
  216.      * @param e7 the seventh element
  217.      * @param e8 the eighth element
  218.      * @param e9 the ninth element
  219.      * @param e10 the tenth element
  220.      * @return a {@code List} containing the specified elements
  221.      * @throws NullPointerException if an element is {@code null}
  222.      *
  223.      * @since 9
  224.      */
  225.     static <E> List<E> of(E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8, E e9, E e10) {
  226.         return new ImmutableCollections.ListN<>(e1, e2, e3, e4, e5,
  227.                                                 e6, e7, e8, e9, e10);
  228.     }
  229.  
  230.     // [...]
  231.  
  232. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement