author | psandoz |
Mon, 02 Feb 2015 14:19:12 +0100 | |
changeset 28754 | 8fe59917548d |
parent 16489 | 53619efef3fb |
child 28963 | 8498cdb7c54b |
permissions | -rw-r--r-- |
16489
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
1 |
/* |
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
2 |
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
4 |
* |
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
8 |
* |
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
13 |
* accompanied this code). |
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
14 |
* |
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
18 |
* |
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
21 |
* questions. |
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
22 |
*/ |
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
23 |
|
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
24 |
/* @test |
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
25 |
* @summary Basic functional test of OptionalInt |
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
26 |
* @author Mike Duigou |
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
27 |
* @run testng BasicInt |
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
28 |
*/ |
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
29 |
|
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
30 |
import java.util.NoSuchElementException; |
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
31 |
import java.util.OptionalInt; |
28754
8fe59917548d
8050820: Please add java.util.Optional.stream() to convert Optional<T> to Stream<T>
psandoz
parents:
16489
diff
changeset
|
32 |
import java.util.stream.IntStream; |
16489
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
33 |
|
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
34 |
import static org.testng.Assert.*; |
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
35 |
import org.testng.annotations.Test; |
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
36 |
|
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
37 |
|
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
38 |
public class BasicInt { |
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
39 |
|
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
40 |
@Test(groups = "unit") |
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
41 |
public void testEmpty() { |
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
42 |
OptionalInt empty = OptionalInt.empty(); |
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
43 |
OptionalInt present = OptionalInt.of(1); |
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
44 |
|
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
45 |
// empty |
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
46 |
assertTrue(empty.equals(empty)); |
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
47 |
assertTrue(empty.equals(OptionalInt.empty())); |
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
48 |
assertTrue(!empty.equals(present)); |
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
49 |
assertTrue(0 == empty.hashCode()); |
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
50 |
assertTrue(!empty.toString().isEmpty()); |
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
51 |
assertTrue(!empty.isPresent()); |
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
52 |
empty.ifPresent(v -> { fail(); }); |
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
53 |
assertEquals(2, empty.orElse(2)); |
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
54 |
assertEquals(2, empty.orElseGet(()-> 2)); |
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
55 |
} |
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
56 |
|
28754
8fe59917548d
8050820: Please add java.util.Optional.stream() to convert Optional<T> to Stream<T>
psandoz
parents:
16489
diff
changeset
|
57 |
@Test(expectedExceptions=NoSuchElementException.class) |
8fe59917548d
8050820: Please add java.util.Optional.stream() to convert Optional<T> to Stream<T>
psandoz
parents:
16489
diff
changeset
|
58 |
public void testEmptyGet() { |
8fe59917548d
8050820: Please add java.util.Optional.stream() to convert Optional<T> to Stream<T>
psandoz
parents:
16489
diff
changeset
|
59 |
OptionalInt empty = OptionalInt.empty(); |
16489
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
60 |
|
28754
8fe59917548d
8050820: Please add java.util.Optional.stream() to convert Optional<T> to Stream<T>
psandoz
parents:
16489
diff
changeset
|
61 |
int got = empty.getAsInt(); |
8fe59917548d
8050820: Please add java.util.Optional.stream() to convert Optional<T> to Stream<T>
psandoz
parents:
16489
diff
changeset
|
62 |
} |
16489
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
63 |
|
28754
8fe59917548d
8050820: Please add java.util.Optional.stream() to convert Optional<T> to Stream<T>
psandoz
parents:
16489
diff
changeset
|
64 |
@Test(expectedExceptions=NullPointerException.class) |
8fe59917548d
8050820: Please add java.util.Optional.stream() to convert Optional<T> to Stream<T>
psandoz
parents:
16489
diff
changeset
|
65 |
public void testEmptyOrElseGetNull() { |
8fe59917548d
8050820: Please add java.util.Optional.stream() to convert Optional<T> to Stream<T>
psandoz
parents:
16489
diff
changeset
|
66 |
OptionalInt empty = OptionalInt.empty(); |
16489
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
67 |
|
28754
8fe59917548d
8050820: Please add java.util.Optional.stream() to convert Optional<T> to Stream<T>
psandoz
parents:
16489
diff
changeset
|
68 |
int got = empty.orElseGet(null); |
8fe59917548d
8050820: Please add java.util.Optional.stream() to convert Optional<T> to Stream<T>
psandoz
parents:
16489
diff
changeset
|
69 |
} |
16489
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
70 |
|
28754
8fe59917548d
8050820: Please add java.util.Optional.stream() to convert Optional<T> to Stream<T>
psandoz
parents:
16489
diff
changeset
|
71 |
@Test(expectedExceptions=NullPointerException.class) |
8fe59917548d
8050820: Please add java.util.Optional.stream() to convert Optional<T> to Stream<T>
psandoz
parents:
16489
diff
changeset
|
72 |
public void testEmptyOrElseThrowNull() throws Throwable { |
8fe59917548d
8050820: Please add java.util.Optional.stream() to convert Optional<T> to Stream<T>
psandoz
parents:
16489
diff
changeset
|
73 |
OptionalInt empty = OptionalInt.empty(); |
16489
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
74 |
|
28754
8fe59917548d
8050820: Please add java.util.Optional.stream() to convert Optional<T> to Stream<T>
psandoz
parents:
16489
diff
changeset
|
75 |
int got = empty.orElseThrow(null); |
8fe59917548d
8050820: Please add java.util.Optional.stream() to convert Optional<T> to Stream<T>
psandoz
parents:
16489
diff
changeset
|
76 |
} |
16489
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
77 |
|
28754
8fe59917548d
8050820: Please add java.util.Optional.stream() to convert Optional<T> to Stream<T>
psandoz
parents:
16489
diff
changeset
|
78 |
@Test(expectedExceptions=ObscureException.class) |
8fe59917548d
8050820: Please add java.util.Optional.stream() to convert Optional<T> to Stream<T>
psandoz
parents:
16489
diff
changeset
|
79 |
public void testEmptyOrElseThrow() throws Exception { |
8fe59917548d
8050820: Please add java.util.Optional.stream() to convert Optional<T> to Stream<T>
psandoz
parents:
16489
diff
changeset
|
80 |
OptionalInt empty = OptionalInt.empty(); |
16489
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
81 |
|
28754
8fe59917548d
8050820: Please add java.util.Optional.stream() to convert Optional<T> to Stream<T>
psandoz
parents:
16489
diff
changeset
|
82 |
int got = empty.orElseThrow(ObscureException::new); |
8fe59917548d
8050820: Please add java.util.Optional.stream() to convert Optional<T> to Stream<T>
psandoz
parents:
16489
diff
changeset
|
83 |
} |
16489
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
84 |
|
28754
8fe59917548d
8050820: Please add java.util.Optional.stream() to convert Optional<T> to Stream<T>
psandoz
parents:
16489
diff
changeset
|
85 |
@Test(groups = "unit") |
8fe59917548d
8050820: Please add java.util.Optional.stream() to convert Optional<T> to Stream<T>
psandoz
parents:
16489
diff
changeset
|
86 |
public void testPresent() { |
16489
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
87 |
OptionalInt empty = OptionalInt.empty(); |
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
88 |
OptionalInt present = OptionalInt.of(1); |
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
89 |
|
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
90 |
// present |
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
91 |
assertTrue(present.equals(present)); |
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
92 |
assertFalse(present.equals(OptionalInt.of(0))); |
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
93 |
assertTrue(present.equals(OptionalInt.of(1))); |
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
94 |
assertFalse(present.equals(empty)); |
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
95 |
assertTrue(Integer.hashCode(1) == present.hashCode()); |
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
96 |
assertFalse(present.toString().isEmpty()); |
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
97 |
assertTrue(-1 != present.toString().indexOf(Integer.toString(present.getAsInt()).toString())); |
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
98 |
assertEquals(1, present.getAsInt()); |
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
99 |
try { |
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
100 |
present.ifPresent(v -> { throw new ObscureException(); }); |
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
101 |
fail(); |
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
102 |
} catch(ObscureException expected) { |
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
103 |
|
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
104 |
} |
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
105 |
assertEquals(1, present.orElse(2)); |
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
106 |
assertEquals(1, present.orElseGet(null)); |
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
107 |
assertEquals(1, present.orElseGet(()-> 2)); |
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
108 |
assertEquals(1, present.orElseGet(()-> 3)); |
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
109 |
assertEquals(1, present.<RuntimeException>orElseThrow(null)); |
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
110 |
assertEquals(1, present.<RuntimeException>orElseThrow(ObscureException::new)); |
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
111 |
} |
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
112 |
|
28754
8fe59917548d
8050820: Please add java.util.Optional.stream() to convert Optional<T> to Stream<T>
psandoz
parents:
16489
diff
changeset
|
113 |
@Test(groups = "unit") |
8fe59917548d
8050820: Please add java.util.Optional.stream() to convert Optional<T> to Stream<T>
psandoz
parents:
16489
diff
changeset
|
114 |
public void testStream() { |
8fe59917548d
8050820: Please add java.util.Optional.stream() to convert Optional<T> to Stream<T>
psandoz
parents:
16489
diff
changeset
|
115 |
{ |
8fe59917548d
8050820: Please add java.util.Optional.stream() to convert Optional<T> to Stream<T>
psandoz
parents:
16489
diff
changeset
|
116 |
IntStream s = OptionalInt.empty().stream(); |
8fe59917548d
8050820: Please add java.util.Optional.stream() to convert Optional<T> to Stream<T>
psandoz
parents:
16489
diff
changeset
|
117 |
assertFalse(s.isParallel()); |
8fe59917548d
8050820: Please add java.util.Optional.stream() to convert Optional<T> to Stream<T>
psandoz
parents:
16489
diff
changeset
|
118 |
|
8fe59917548d
8050820: Please add java.util.Optional.stream() to convert Optional<T> to Stream<T>
psandoz
parents:
16489
diff
changeset
|
119 |
int[] es = s.toArray(); |
8fe59917548d
8050820: Please add java.util.Optional.stream() to convert Optional<T> to Stream<T>
psandoz
parents:
16489
diff
changeset
|
120 |
assertEquals(es.length, 0); |
8fe59917548d
8050820: Please add java.util.Optional.stream() to convert Optional<T> to Stream<T>
psandoz
parents:
16489
diff
changeset
|
121 |
} |
8fe59917548d
8050820: Please add java.util.Optional.stream() to convert Optional<T> to Stream<T>
psandoz
parents:
16489
diff
changeset
|
122 |
|
8fe59917548d
8050820: Please add java.util.Optional.stream() to convert Optional<T> to Stream<T>
psandoz
parents:
16489
diff
changeset
|
123 |
{ |
8fe59917548d
8050820: Please add java.util.Optional.stream() to convert Optional<T> to Stream<T>
psandoz
parents:
16489
diff
changeset
|
124 |
IntStream s = OptionalInt.of(42).stream(); |
8fe59917548d
8050820: Please add java.util.Optional.stream() to convert Optional<T> to Stream<T>
psandoz
parents:
16489
diff
changeset
|
125 |
assertFalse(s.isParallel()); |
8fe59917548d
8050820: Please add java.util.Optional.stream() to convert Optional<T> to Stream<T>
psandoz
parents:
16489
diff
changeset
|
126 |
|
8fe59917548d
8050820: Please add java.util.Optional.stream() to convert Optional<T> to Stream<T>
psandoz
parents:
16489
diff
changeset
|
127 |
int[] es = OptionalInt.of(42).stream().toArray(); |
8fe59917548d
8050820: Please add java.util.Optional.stream() to convert Optional<T> to Stream<T>
psandoz
parents:
16489
diff
changeset
|
128 |
assertEquals(es.length, 1); |
8fe59917548d
8050820: Please add java.util.Optional.stream() to convert Optional<T> to Stream<T>
psandoz
parents:
16489
diff
changeset
|
129 |
assertEquals(es[0], 42); |
8fe59917548d
8050820: Please add java.util.Optional.stream() to convert Optional<T> to Stream<T>
psandoz
parents:
16489
diff
changeset
|
130 |
} |
8fe59917548d
8050820: Please add java.util.Optional.stream() to convert Optional<T> to Stream<T>
psandoz
parents:
16489
diff
changeset
|
131 |
} |
8fe59917548d
8050820: Please add java.util.Optional.stream() to convert Optional<T> to Stream<T>
psandoz
parents:
16489
diff
changeset
|
132 |
|
16489
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
133 |
private static class ObscureException extends RuntimeException { |
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
134 |
|
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
135 |
} |
53619efef3fb
8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
mduigou
parents:
diff
changeset
|
136 |
} |