View Javadoc
1   /*
2    * Copyright (C) 2012-2024 RRiBbit.org
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * https://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.rribbit;
17  
18  import java.io.Serializable;
19  import java.util.Collection;
20  
21  import org.rribbit.dispatching.RequestDispatcher;
22  import org.rribbit.processing.RequestProcessor;
23  
24  /**
25   * This class represents a response to a {@link Request} that is given back by the {@link RequestProcessor} to the {@link RequestDispatcher}.
26   * <p />
27   * The {@link Collection}s in this object should never be null, but may be empty.
28   * <p />
29   * This class implements {@link Serializable}, but in order to be truly serializable, the user should make sure that the {@link Object}s in the returnValues are also {@link Serializable}.
30   *
31   * @param <T> The type of the return values
32   *
33   * @author G.J. Schouten
34   *
35   */
36  public class Response<T> implements Serializable {
37  
38  	private Collection<T> returnValues;
39  	private Collection<Throwable> throwables;
40  
41  	public Response(Collection<T> returnValues, Collection<Throwable> throwables) {
42  		this.returnValues = returnValues;
43  		this.throwables = throwables;
44  	}
45  
46  	public Collection<T> getReturnValues() {
47  		return returnValues;
48  	}
49  
50  	public Collection<Throwable> getThrowables() {
51  		return throwables;
52  	}
53  }