-
Notifications
You must be signed in to change notification settings - Fork 5
/
Success.java
46 lines (39 loc) · 881 Bytes
/
Success.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*
* © 2022. TU Dortmund University,
* Institute of Energy Systems, Energy Efficiency and Energy Economics,
* Research group Distribution grid planning and operation
*/
package edu.ie3.datamodel.utils.options;
public class Success<R, E extends Exception> extends Try<R, E> {
/** Private fields. */
private final R data;
public Success(R data) {
super(data == null);
this.data = data;
}
/**
* Method to create an empty success.
*
* @return empty {@link Success}
*/
public static <E extends Exception> Success<Void, E> empty() {
return new Success<>(null);
}
@Override
public boolean isSuccess() {
return true;
}
@Override
public boolean isFailure() {
return false;
}
/** Returns the data. */
@Override
public R getData() {
return data;
}
@Override
public E getException() {
return null;
}
}