1 /*
2 * Copyright (C) 2012-2025 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 org.rribbit.dispatching.RequestDispatcher;
19 import org.rribbit.processing.RequestProcessor;
20
21 import java.io.Serializable;
22
23 /**
24 * This class represents a request that is made to the {@link RequestResponseBus}. It is passed to a {@link RequestDispatcher} for dispatching to a {@link RequestProcessor}.
25 * <p />
26 * The hint and the desiredReturnType can be null if this request does not care about the returntype or if this request does not want to select listeners based on a hint.
27 * <p />
28 * This class implements {@link Serializable}, but in order to be truly serializable, the user should make sure that the {@link Object}s in the parameters are also {@link Serializable}.
29 *
30 * @author G.J. Schouten
31 *
32 */
33 public class Request implements Serializable {
34
35 private String hint;
36 private Class<?> desiredReturnType;
37 private Object[] parameters;
38
39 public Request(Class<?> desiredReturnType, String hint, Object[] parameters) {
40 this.hint = hint;
41 this.desiredReturnType = desiredReturnType;
42 this.parameters = parameters;
43 }
44
45 public String getHint() {
46 return hint;
47 }
48
49 public Class<?> getDesiredReturnType() {
50 return desiredReturnType;
51 }
52
53 public Object[] getParameters() {
54 return parameters;
55 }
56 }