Request.java

/*
 * Copyright (C) 2012-2024 RRiBbit.org
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.rribbit;

import org.rribbit.dispatching.RequestDispatcher;
import org.rribbit.processing.RequestProcessor;

import java.io.Serializable;

/**
 * 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}.
 * <p />
 * 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.
 * <p />
 * 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}.
 *
 * @author G.J. Schouten
 *
 */
public class Request implements Serializable {

	private String hint;
	private Class<?> desiredReturnType;
	private Object[] parameters;

	public Request(Class<?> desiredReturnType, String hint, Object[] parameters) {
		this.hint = hint;
		this.desiredReturnType = desiredReturnType;
		this.parameters = parameters;
	}

	public String getHint() {
		return hint;
	}

	public Class<?> getDesiredReturnType() {
		return desiredReturnType;
	}

	public Object[] getParameters() {
		return parameters;
	}
}