fuin.org
Small Open Source Java Tools and Libraries
Asserting methods are not used
Example:
Prevent a "java.lang.ArithmeticException: Non-terminating decimal expansion; no exact representable decimal result.
" caused by calling
BigDecimal's divide
or setScale
without a rounding mode:
// Path to '*.class' files final File classesDir = new File("target/classes"); // Can be used to exclude some files/packages final FileFilter fileFilter = new FileFilter() { @Override public boolean accept(File file) { return !file.getPath().contains("my/pkg/to/exclude"); } }; // Define methods to find final MCAMethod divide = new MCAMethod("java.math.BigDecimal", "java.math.BigDecimal divide(java.math.BigDecimal)"); final MCAMethod setScale = new MCAMethod("java.math.BigDecimal", "java.math.BigDecimal setScale(int)"); // Fails if any class calls one of the two methods AssertUsage.assertMethodsNotUsed(classesDir, fileFilter, divide, setScale);