Package org.onlab.junit
Class UtilityClassChecker
- java.lang.Object
-
- org.onlab.junit.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 Summary
Constructors Constructor Description UtilityClassChecker()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static voidassertThatClassIsUtility(Class<?> clazz)Assert that the given class adheres to the utility class rules.voiddescribeMismatch(org.hamcrest.Description description)Describe why an error was reported.voiddescribeTo(org.hamcrest.Description description)Describe the source object that caused an error, using a Hamcrest Matcher style interface.
-
-
-
Method Detail
-
describeMismatch
public void describeMismatch(org.hamcrest.Description description)
Describe why an error was reported. Uses Hamcrest style Description interfaces.- Parameters:
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.- Parameters:
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.- Parameters:
clazz- the class to check- Throws:
AssertionError- if the class is not a valid utility class
-
-