Package: BlockTask

BlockTask

nameinstructionbranchcomplexitylinemethod
BlockTask(int, int, Mode)
M: 0 C: 12
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
getMode()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getParent()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
setParent(ToplevelBlockTask)
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2017 Eurotech and/or its affiliates and others
3: *
4: * All rights reserved. This program and the accompanying materials
5: * are made available under the terms of the Eclipse Public License v1.0
6: * which accompanies this distribution, and is available at
7: * http://www.eclipse.org/legal/epl-v10.html
8: *
9: * Contributors:
10: * Eurotech
11: *******************************************************************************/
12:
13: package org.eclipse.kura.driver.block.task;
14:
15: import static java.util.Objects.requireNonNull;
16:
17: import java.io.IOException;
18:
19: import org.eclipse.kura.driver.block.Block;
20:
21: /**
22: * This class represents an generic operation that involves a specific interval of addresses on a given address space.
23: *
24: * @see BlockTaskAggregator
25: * @see ToplevelBlockTask
26: */
27: public abstract class BlockTask extends Block {
28:
29: private final Mode mode;
30: private ToplevelBlockTask parent;
31:
32: /**
33: * Creates a new {@link BlockTask}
34: *
35: * @param start
36: * the start address of the interval involved by the operation
37: * @param end
38: * the end address of the interval involved by the operation
39: * @param mode
40: * the {@link Mode} of the operation
41: */
42: public BlockTask(int start, int end, Mode mode) {
43: super(start, end);
44: requireNonNull(mode, "The provided mode cannot be null");
45: this.mode = mode;
46: }
47:
48: /**
49: * Sets the parent of this task.
50: *
51: * @see BlockTaskAggregator
52: * @param parent
53: * the parent task
54: */
55: public void setParent(ToplevelBlockTask parent) {
56: this.parent = parent;
57: }
58:
59: /**
60: * Returns the parent of this task.
61: *
62: * @return the parent task, or {@code null} if this task has no parent.
63: */
64: public ToplevelBlockTask getParent() {
65: return this.parent;
66: }
67:
68: /**
69: * Returns the {@link Mode} of this task.
70: *
71: * @return the {@link Mode} of this task
72: */
73: public Mode getMode() {
74: return this.mode;
75: }
76:
77: /**
78: * Performs the operation described by this task.
79: *
80: * @throws IOException
81: * If an I/O error occurs during the operation
82: */
83: public abstract void run() throws IOException;
84:
85: /**
86: * Notifies this task that the operation performed by the parent task is failed.
87: *
88: * @param reason
89: * An {@link Exception} instance describing the reason of the failure
90: */
91: public abstract void onFailure(Exception exception);
92:
93: /**
94: * Notifies this task that the operation performed by the parent task failed.
95: */
96: public abstract void onSuccess();
97:
98: }