AnswerReturnValuesAdapter.java revision e0ae5d7e87b1dd6e789803c1b9615a84bd7488b7
1/*
2 * Copyright (c) 2007 Mockito contributors
3 * This program is made available under the terms of the MIT License.
4 */
5package org.mockito.internal.stubbing.answers;
6
7import java.io.Serializable;
8
9import org.mockito.ReturnValues;
10import org.mockito.invocation.InvocationOnMock;
11import org.mockito.stubbing.Answer;
12
13//It's ok to suppress deprecation because this class goes away as soon as ReturnValues disappears in future release
14@SuppressWarnings("deprecation")
15public class AnswerReturnValuesAdapter implements Answer<Object>, Serializable {
16
17    private static final long serialVersionUID = 1418158596876713469L;
18    private final ReturnValues returnValues;
19
20    public AnswerReturnValuesAdapter(ReturnValues returnValues) {
21        this.returnValues = returnValues;
22    }
23
24    public Object answer(InvocationOnMock invocation) throws Throwable {
25        return returnValues.valueFor(invocation);
26    }
27}