Enables isTypeMockable() in public source.
Change on 2019/06/24 by tball
@@ -14,6 +14,7 @@ package com.google.j2objc.mockito;
import java.lang.ref.WeakReference;
import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Modifier;
import java.lang.reflect.Proxy;
import java.util.HashMap;
import java.util.Map;
@@ -49,7 +50,7 @@ public final class IosMockMaker implements MockMaker {
public <T> T createMock(MockCreationSettings<T> settings, MockHandler handler) {
Class<T> typeToMock = settings.getTypeToMock();
@SuppressWarnings("rawtypes")
-Set<Class> interfacesSet = settings.getExtraInterfaces();
+ Set<Class<?>> interfacesSet = settings.getExtraInterfaces();
Class<?>[] extraInterfaces = interfacesSet.toArray(new Class<?>[interfacesSet.size()]);
InvocationHandler invocationHandler = new InvocationHandlerAdapter(handler);
@@ -223,6 +224,29 @@ Set<Class> interfacesSet = settings.getExtraInterfaces();
]-*/
}
+ @Override
+ public TypeMockability isTypeMockable(final Class<?> type) {
+ return new TypeMockability() {
+ @Override
+ public boolean mockable() {
+ return !type.isPrimitive() && !Modifier.isFinal(type.getModifiers());
+ }
+
+ @Override
+ public String nonMockableReason() {
+ if (mockable()) {
+ return "";
+ }
+ if (type.isPrimitive()) {
+ return "primitive type";
+ }
+ if (Modifier.isFinal(type.getModifiers())) {
+ return "final class";
+ }
+ return "not handled type";
+ }
+ };
+ }
}
/*-[
