private void saniteettitarkastus() throws SecurityException { Field[] kentat = ReflectionUtils.findClass(luokanNimi).getDeclaredFields(); for (Field field : kentat) { assertFalse( "does not need \"static variables\", remove " + kentta(field.toString()), field.toString().contains("static") && !field.toString().contains("final")); assertTrue( "all the object variables should be private, please change " + kentta(field.toString()), field.toString().contains("private")); } if (kentat.length > 1) { int var = 0; for (Field field : kentat) { if (!field.toString().contains("final")) { var++; } } assertTrue( "The class " + luokanNimi + " needs only instance variable for the amount of weightings, remove the extra " + "", var < 2); } }
private void saniteettitarkastus(int n, String m) throws SecurityException { Field[] kentat = ReflectionUtils.findClass(luokanNimi).getDeclaredFields(); for (Field field : kentat) { assertFalse( "does not need \"static variables\", remove " + kentta(field.toString()), field.toString().contains("static") && !field.toString().contains("final")); assertTrue( "all the object variables should be private, please change " + kentta(field.toString()), field.toString().contains("private")); } if (kentat.length > 1) { int var = 0; for (Field field : kentat) { if (!field.toString().contains("final")) { var++; System.err.println("JAMO:fields"); } } String s = n > 1 ? "s" : ""; assertTrue( "The class " + klassName + " needs instance variable" + s + " only for " + m + ", remove the rest", var <= n); } }