Autopsy  4.16.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
DataFetchResult.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2020 Basis Technology Corp.
5  * Contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 package org.sleuthkit.autopsy.datasourcesummary.uiutils;
20 
24 public final class DataFetchResult<R> {
25 
29  public enum ResultType {
30  SUCCESS, ERROR
31  }
32 
40  public static <R> DataFetchResult<R> getSuccessResult(R data) {
41  return new DataFetchResult<>(ResultType.SUCCESS, data, null);
42  }
43 
51  public static <R> DataFetchResult<R> getErrorResult(Throwable e) {
52  return new DataFetchResult<>(ResultType.ERROR, null, e);
53  }
54 
55  private final ResultType state;
56  private final R data;
57  private final Throwable exception;
58 
67  private DataFetchResult(ResultType state, R data, Throwable exception) {
68  this.state = state;
69  this.data = data;
70  this.exception = exception;
71  }
72 
77  return state;
78  }
79 
83  public R getData() {
84  return data;
85  }
86 
90  public Throwable getException() {
91  return exception;
92  }
93 }
static< R > DataFetchResult< R > getErrorResult(Throwable e)
DataFetchResult(ResultType state, R data, Throwable exception)
static< R > DataFetchResult< R > getSuccessResult(R data)

Copyright © 2012-2020 Basis Technology. Generated on: Tue Sep 22 2020
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.