View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  
18  package com.github.dexecutor.executor;
19  /**
20   * Holds execution result of a node identified by id 
21   * 
22   * @author Nadeem Mohammad
23   *
24   * @param <T> Type of Node/Task ID
25   * @param <R> Type of Node/Task result
26   */
27  public class ExecutionResult <T, R> {
28  
29  	private T id;
30  	private R result;
31  	private ExecutionStatus status;
32  
33  	public ExecutionResult(final T id, final R result, ExecutionStatus status) {
34  		this.id = id;
35  		this.result = result;
36  		this.status = status;
37  	}
38  	/**
39  	 * 
40  	 * @return the id of the executing node
41  	 */
42  	public T getId() {
43  		return id;
44  	}
45  	/**
46  	 * 
47  	 * @return result of execution
48  	 */
49  	public R getResult() {
50  		return result;
51  	}
52  	/**
53  	 * 
54  	 * @return {@code true} if the result is success
55  	 * {@code false} if the result is not success
56  	 */
57  	public boolean isSuccess() {
58  		return ExecutionStatus.SUCCESS.equals(this.status);
59  	}
60  	/**
61  	 * 
62  	 * @return {@code true} if the result is error
63  	 * {@code false} if the result is not error
64  	 */
65  	public boolean isErrored() {
66  		return ExecutionStatus.ERRORED.equals(this.status);
67  	}
68  	/**
69  	 * 
70  	 * @return {@code true} if the result is skipped
71  	 * {@code false} if the result is not skipped
72  	 */
73  	public boolean isSkipped() {
74  		return ExecutionStatus.SKIPPED.equals(this.status);
75  	}
76  
77  	@Override
78  	public String toString() {
79  		return "ExecutionResult [id=" + id + ", result=" + result + ", status=" + status + "]";
80  	}	
81  }