Skip to content

Package: Task8$3

Task8$3

nameinstructionbranchcomplexitylinemethod
run()
M: 5 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
{...}
M: 6 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*
2: * #%L
3: * *********************************************************************************************************************
4: *
5: * NorthernWind - lightweight CMS
6: * http://northernwind.tidalwave.it - git clone git@bitbucket.org:tidalwave/northernwind-rca-src.git
7: * %%
8: * Copyright (C) 2013 - 2016 Tidalwave s.a.s. (http://tidalwave.it)
9: * %%
10: * *********************************************************************************************************************
11: *
12: * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
13: * the License. You may obtain a copy of the License at
14: *
15: * http://www.apache.org/licenses/LICENSE-2.0
16: *
17: * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
18: * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
19: * specific language governing permissions and limitations under the License.
20: *
21: * *********************************************************************************************************************
22: *
23: * $Id$
24: *
25: * *********************************************************************************************************************
26: * #L%
27: */
28: package it.tidalwave.util;
29:
30: import javax.annotation.Nonnull;
31: import java.util.concurrent.Callable;
32:
33: /***********************************************************************************************************************
34: *
35: * Java 8 extensions for {@link Task}
36: *
37: * @author Fabrizio Giudici (Fabrizio.Giudici@tidalwave.it)
38: * @version $Id$
39: * @since 3.0
40: *
41: **********************************************************************************************************************/
42: public abstract class Task8<T, E extends Throwable> extends Task<T, E>
43: {
44: /*******************************************************************************************************************
45: *
46: * Creates a {@code Task} from a {@link Runnable}.
47: *
48: * @param runnable the wrapped object
49: * @return the {@code Task}
50: *
51: ******************************************************************************************************************/
52: @Nonnull
53: public static Task8<Void, RuntimeException> ofRunnable (final @Nonnull Runnable runnable)
54: {
55: return new Task8<Void, RuntimeException>()
56: {
57: @Override
58: public Void run()
59: {
60: runnable.run();
61: return null;
62: }
63: };
64: }
65:
66: /*******************************************************************************************************************
67: *
68: * Creates a {@code Task} from a {@link Callable}.
69: *
70: * @param callable the wrapped object
71: * @return the {@code Task}
72: *
73: ******************************************************************************************************************/
74: @Nonnull
75: public static <T> Task8<T, Exception> ofCallable (final @Nonnull Callable<T> callable)
76: {
77: return new Task8<T, Exception>()
78: {
79: @Override
80: public T run()
81: throws Exception
82: {
83: return callable.call();
84: }
85: };
86: }
87:
88: /*******************************************************************************************************************
89: *
90: * Creates a {@code Task} from a {@link Callback}.
91: *
92: * @param callback the wrapped object
93: * @return the {@code Task}
94: *
95: ******************************************************************************************************************/
96: @Nonnull
97: public static Task8<Void, Throwable> ofCallback (final @Nonnull Callback callback)
98: {
99: return new Task8<Void, Throwable>()
100: {
101: @Override
102: public Void run()
103: throws Throwable
104: {
105: callback.call();
106: return null;
107: }
108: };
109: }
110: }