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.invocation.InvocationOnMock;
10import org.mockito.stubbing.Answer;
11
12public class Returns implements Answer<Object>, Serializable {
13
14    private static final long serialVersionUID = -6245608253574215396L;
15    private final Object value;
16
17    public Returns(Object value) {
18        this.value = value;
19    }
20
21    public Object answer(InvocationOnMock invocation) throws Throwable {
22        return value;
23    }
24
25    public String printReturnType() {
26        return value.getClass().getSimpleName();
27    }
28
29    public Class<?> getReturnType() {
30        return value.getClass();
31    }
32
33    public boolean returnsNull() {
34        return value == null;
35    }
36
37    @Override
38    public String toString() {
39        return "Returns: " + value;
40    }
41}