All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.fitbur.mockito.internal.creation.settings.CreationSettings Maven / Gradle / Ivy

There is a newer version: 1.0.0
Show newest version
/*
 * Copyright (c) 2007 Mockito contributors
 * This program is made available under the terms of the MIT License.
 */
package com.fitbur.mockito.internal.creation.settings;

import com.fitbur.mockito.listeners.InvocationListener;
import com.fitbur.mockito.mock.MockCreationSettings;
import com.fitbur.mockito.mock.MockName;
import com.fitbur.mockito.mock.SerializableMode;
import com.fitbur.mockito.stubbing.Answer;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;

/**
 * by Szczepan Faber, created at: 4/9/12
 */
public class CreationSettings implements MockCreationSettings, Serializable {
    private static final long serialVersionUID = -6789800638070123629L;

    protected Class typeToMock;
    protected Set> extraInterfaces = new LinkedHashSet>();
    protected String name;
    protected Object spiedInstance;
    protected Answer defaultAnswer;
    protected MockName mockName;
    protected SerializableMode serializableMode = SerializableMode.NONE;
    protected List invocationListeners = new ArrayList();
    protected boolean stubOnly;
    private boolean useConstructor;
    private Object outerClassInstance;

    public CreationSettings() {}

    @SuppressWarnings("unchecked")
    public CreationSettings(CreationSettings copy) {
        this.typeToMock = copy.typeToMock;
        this.extraInterfaces = copy.extraInterfaces;
        this.name = copy.name;
        this.spiedInstance = copy.spiedInstance;
        this.defaultAnswer = copy.defaultAnswer;
        this.mockName = copy.mockName;
        this.serializableMode = copy.serializableMode;
        this.invocationListeners = copy.invocationListeners;
        this.stubOnly = copy.stubOnly;
        this.useConstructor = copy.isUsingConstructor();
        this.outerClassInstance = copy.getOuterClassInstance();
    }

    public Class getTypeToMock() {
        return typeToMock;
    }

    public CreationSettings setTypeToMock(Class typeToMock) {
        this.typeToMock = typeToMock;
        return this;
    }

    public Set> getExtraInterfaces() {
        return extraInterfaces;
    }

    public CreationSettings setExtraInterfaces(Set> extraInterfaces) {
        this.extraInterfaces = extraInterfaces;
        return this;
    }

    public String getName() {
        return name;
    }

    public Object getSpiedInstance() {
        return spiedInstance;
    }

    public Answer getDefaultAnswer() {
        return defaultAnswer;
    }

    public MockName getMockName() {
        return mockName;
    }

    public CreationSettings setMockName(MockName mockName) {
        this.mockName = mockName;
        return this;
    }

    public boolean isSerializable() {
        return serializableMode != SerializableMode.NONE;
    }

    public SerializableMode getSerializableMode() {
        return serializableMode;
    }

    public List getInvocationListeners() {
        return invocationListeners;
    }

    public boolean isUsingConstructor() {
        return useConstructor;
    }

    public Object getOuterClassInstance() {
        return outerClassInstance;
    }

    public boolean isStubOnly() {
        return stubOnly;
    }

}