Update of /cvsroot/mocklib/mocklib3/input/javasrc/biz/xsoftware/impl/mock
In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv24881/input/javasrc/biz/xsoftware/impl/mock
Modified Files:
MockObjectImpl.java
Log Message:
Changed set and map to be static final because they're shared across all instances and shouldn't be changed after static init. This required the name to be all caps constant so checkstyle would pass
Index: MockObjectImpl.java
===================================================================
RCS file: /cvsroot/mocklib/mocklib3/input/javasrc/biz/xsoftware/impl/mock/MockObjectImpl.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** MockObjectImpl.java 11 Feb 2009 18:32:00 -0000 1.5
--- MockObjectImpl.java 11 Feb 2009 19:07:50 -0000 1.6
***************
*** 41,48 ****
Logger.getLogger(MockObjectImpl.class.getName());
! private static final Set<Method> isMethodInSuper = new HashSet<Method>();
! private static final Map<Type, Class<?>> primitiveToClass =
! new HashMap<Type, Class<?>>();
private Class<?>[] classes;
--- 41,47 ----
Logger.getLogger(MockObjectImpl.class.getName());
! private static final Set<Method> METHOD_IN_SUPER_SET = new HashSet<Method>();
! private static final Map<Type, Class<?>> PRIMITIVE_TO_CLASS_MAP = new HashMap<Type, Class<?>>();
private Class<?>[] classes;
***************
*** 53,72 ****
Method[] m = c.getMethods();
for (int i = 0; i < m.length; i++) {
! isMethodInSuper.add(m[i]);
}
c = Object.class;
m = c.getMethods();
for (int i = 0; i < m.length; i++) {
! isMethodInSuper.add(m[i]);
}
! primitiveToClass.put(Integer.TYPE, Integer.class);
! primitiveToClass.put(Double.TYPE, Double.class);
! primitiveToClass.put(Float.TYPE, Float.class);
! primitiveToClass.put(Boolean.TYPE, Boolean.class);
! primitiveToClass.put(Character.TYPE, Character.class);
! primitiveToClass.put(Byte.TYPE, Byte.class);
! primitiveToClass.put(Short.TYPE, Short.class);
! primitiveToClass.put(Long.TYPE, Long.class);
}
--- 52,71 ----
Method[] m = c.getMethods();
for (int i = 0; i < m.length; i++) {
! METHOD_IN_SUPER_SET.add(m[i]);
}
c = Object.class;
m = c.getMethods();
for (int i = 0; i < m.length; i++) {
! METHOD_IN_SUPER_SET.add(m[i]);
}
! PRIMITIVE_TO_CLASS_MAP.put(Integer.TYPE, Integer.class);
! PRIMITIVE_TO_CLASS_MAP.put(Double.TYPE, Double.class);
! PRIMITIVE_TO_CLASS_MAP.put(Float.TYPE, Float.class);
! PRIMITIVE_TO_CLASS_MAP.put(Boolean.TYPE, Boolean.class);
! PRIMITIVE_TO_CLASS_MAP.put(Character.TYPE, Character.class);
! PRIMITIVE_TO_CLASS_MAP.put(Byte.TYPE, Byte.class);
! PRIMITIVE_TO_CLASS_MAP.put(Short.TYPE, Short.class);
! PRIMITIVE_TO_CLASS_MAP.put(Long.TYPE, Long.class);
}
***************
*** 140,144 ****
// TODO: this is not working correctly no matter what I do
// here.....
! Class<?> primitiveClass = primitiveToClass.get(returnType);
if (!primitiveClass.isInstance(o)) {
throw new IllegalArgumentException(
--- 139,143 ----
// TODO: this is not working correctly no matter what I do
// here.....
! Class<?> primitiveClass = PRIMITIVE_TO_CLASS_MAP.get(returnType);
if (!primitiveClass.isInstance(o)) {
throw new IllegalArgumentException(
***************
*** 166,170 ****
private boolean shouldCallSuperMethod(Method method) {
! return isMethodInSuper.contains(method)
&& !methodToReturnVal.containsKey(method)
&& !methodToDefaultRetVal.containsKey(method);
--- 165,169 ----
private boolean shouldCallSuperMethod(Method method) {
! return METHOD_IN_SUPER_SET.contains(method)
&& !methodToReturnVal.containsKey(method)
&& !methodToDefaultRetVal.containsKey(method);
|