Class UtilityClassChecker

  • public class UtilityClassChecker
    extends Object
    Hamcrest style class for verifying that a class follows the accepted rules for utility classes. The rules that are enforced for utility classes: - the class must be declared final - the class must have only one constructor - the constructor must be private and inaccessible to callers - the class must have only static methods
    • Constructor Detail

      • UtilityClassChecker

        public UtilityClassChecker()
    • Method Detail

      • describeMismatch

        public void describeMismatch​(org.hamcrest.Description description)
        Describe why an error was reported. Uses Hamcrest style Description interfaces.
        description - the Description object to use for reporting the mismatch
      • describeTo

        public void describeTo​(org.hamcrest.Description description)
        Describe the source object that caused an error, using a Hamcrest Matcher style interface. In this case, it always returns that we are looking for a properly defined utility class.
        description - the Description object to use to report the "to" object
      • assertThatClassIsUtility

        public static void assertThatClassIsUtility​(Class<?> clazz)
        Assert that the given class adheres to the utility class rules.
        clazz - the class to check
        AssertionError - if the class is not a valid utility class