org.mockito.internal.creation.instance.DefaultInstantiatorProvider Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mockito-core Show documentation
Show all versions of mockito-core Show documentation
Mockito mock objects library core API and implementation
/*
* Copyright (c) 2016 Mockito contributors
* This program is made available under the terms of the MIT License.
*/
package org.mockito.internal.creation.instance;
import org.mockito.creation.instance.Instantiator;
import org.mockito.mock.MockCreationSettings;
import org.mockito.plugins.InstantiatorProvider2;
public class DefaultInstantiatorProvider implements InstantiatorProvider2 {
private static final Instantiator INSTANCE = new ObjenesisInstantiator();
@Override
public Instantiator getInstantiator(MockCreationSettings settings) {
if (settings != null && settings.getConstructorArgs() != null) {
return new ConstructorInstantiator(
settings.getOuterClassInstance() != null, settings.getConstructorArgs());
} else {
return INSTANCE;
}
}
}