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.creation.settings;
6
7import org.mockito.listeners.InvocationListener;
8import org.mockito.mock.MockCreationSettings;
9import org.mockito.mock.MockName;
10import org.mockito.stubbing.Answer;
11
12import java.io.Serializable;
13import java.util.ArrayList;
14import java.util.LinkedHashSet;
15import java.util.List;
16import java.util.Set;
17
18/**
19 * by Szczepan Faber, created at: 4/9/12
20 */
21public class CreationSettings<T> implements MockCreationSettings<T>, Serializable {
22    private static final long serialVersionUID = -6789800638070123629L;
23
24    protected Class<T> typeToMock;
25    protected Set<Class> extraInterfaces = new LinkedHashSet<Class>();
26    protected String name;
27    protected Object spiedInstance;
28    protected Answer<Object> defaultAnswer;
29    protected MockName mockName;
30    protected boolean serializable;
31    protected List<InvocationListener> invocationListeners = new ArrayList<InvocationListener>();
32    protected boolean stubOnly;
33
34    public CreationSettings() {}
35
36    @SuppressWarnings("unchecked")
37    public CreationSettings(CreationSettings copy) {
38        this.typeToMock = copy.typeToMock;
39        this.extraInterfaces = copy.extraInterfaces;
40        this.name = copy.name;
41        this.spiedInstance = copy.spiedInstance;
42        this.defaultAnswer = copy.defaultAnswer;
43        this.mockName = copy.mockName;
44        this.serializable = copy.serializable;
45        this.invocationListeners = copy.invocationListeners;
46        this.stubOnly = copy.stubOnly;
47    }
48
49    public Class<T> getTypeToMock() {
50        return typeToMock;
51    }
52
53    public CreationSettings<T> setTypeToMock(Class<T> typeToMock) {
54        this.typeToMock = typeToMock;
55        return this;
56    }
57
58    public Set<Class> getExtraInterfaces() {
59        return extraInterfaces;
60    }
61
62    public CreationSettings<T> setExtraInterfaces(Set<Class> extraInterfaces) {
63        this.extraInterfaces = extraInterfaces;
64        return this;
65    }
66
67    public String getName() {
68        return name;
69    }
70
71    public Object getSpiedInstance() {
72        return spiedInstance;
73    }
74
75    public Answer<Object> getDefaultAnswer() {
76        return defaultAnswer;
77    }
78
79    public MockName getMockName() {
80        return mockName;
81    }
82
83    public CreationSettings<T> setMockName(MockName mockName) {
84        this.mockName = mockName;
85        return this;
86    }
87
88    public boolean isSerializable() {
89        return serializable;
90    }
91
92    public List<InvocationListener> getInvocationListeners() {
93        return invocationListeners;
94    }
95
96    public boolean isStubOnly() {
97        return stubOnly;
98    }
99
100}
101