Class AssertUtils
- java.lang.Object
-
- io.nuun.kernel.core.internal.utils.AssertUtils
-
public class AssertUtils extends Object
Provides assertions commonly used by Nuun plugins.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAssertUtils.AnnotationCopy
-
Constructor Summary
Constructors Constructor Description AssertUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <A extends Annotation>
AannotationProxyOf(Class<A> annotationModelType, Annotation annotationClone)static voidassertInterface(Class<? extends Object> candidate)Asserts that the given class is an interface.static voidassertionIllegalArgument(boolean asserted, String message)Asserts that the given parameter is true, otherwise throws anIllegalArgumentException.static voidassertionNullPointer(boolean asserted, String message)Asserts that the given parameter is true, otherwise throws anNullPointerException.static voidassertIsClass(Class<? extends Object> candidate)Asserts that the class is not an interface.static voidassertLegal(Object underAssertion, String message)Asserts that the given parameter is not null, otherwise throws anIllegalArgumentException.static voidassertNotNull(Object underAssertion, String message)Asserts that the given parameter is not null, otherwise throws anNullPointerException.static booleanhasAnnotationDeep(Class<?> memberDeclaringClass, Class<? extends Annotation> candidate)Indicates if a class or at least one of its annotations is annotated by a given annotation.static booleanhasAnnotationDeepRegex(Class<?> memberDeclaringClass, String metaAnnotationRegex)Indicates if the class name or at least the name of one of its annotations matches the regex.static booleanisClass(Class<? extends Object> candidate)Indicates if the class is not an interface.static booleanisEquivalent(Class<? extends Annotation> original, Class<? extends Annotation> copy)static booleanisInterface(Class<? extends Object> candidate)Indicates if the given class is an interface.
-
-
-
Method Detail
-
isInterface
public static boolean isInterface(Class<? extends Object> candidate)
Indicates if the given class is an interface.- Parameters:
candidate- the class to check- Returns:
- true if the class is an interface, false otherwise
-
assertInterface
public static void assertInterface(Class<? extends Object> candidate)
Asserts that the given class is an interface.- Parameters:
candidate- the class to check- Throws:
IllegalArgumentException- if the assertion is not satisfied
-
isClass
public static boolean isClass(Class<? extends Object> candidate)
Indicates if the class is not an interface.- Parameters:
candidate- the class to check- Returns:
- true if class is not an interface, false otherwise
-
assertIsClass
public static void assertIsClass(Class<? extends Object> candidate)
Asserts that the class is not an interface.- Parameters:
candidate- the class to check- Throws:
IllegalArgumentException- if the assertion is not satisfied
-
hasAnnotationDeep
public static boolean hasAnnotationDeep(Class<?> memberDeclaringClass, Class<? extends Annotation> candidate)
Indicates if a class or at least one of its annotations is annotated by a given annotation.Notice that the classes with a package name starting with "java.lang" will be ignored.
- Parameters:
memberDeclaringClass- the class to checkcandidate- the annotation to find- Returns:
- true if the annotation is found, false otherwise
-
hasAnnotationDeepRegex
public static boolean hasAnnotationDeepRegex(Class<?> memberDeclaringClass, String metaAnnotationRegex)
Indicates if the class name or at least the name of one of its annotations matches the regex.Notice that the classes with a package name starting with "java.lang" will be ignored.
- Parameters:
memberDeclaringClass- the class to checkmetaAnnotationRegex- the regex to match- Returns:
- true if the regex matches, false otherwise
-
isEquivalent
public static boolean isEquivalent(Class<? extends Annotation> original, Class<? extends Annotation> copy)
-
annotationProxyOf
public static <A extends Annotation> A annotationProxyOf(Class<A> annotationModelType, Annotation annotationClone)
-
assertionIllegalArgument
public static void assertionIllegalArgument(boolean asserted, String message)Asserts that the given parameter is true, otherwise throws anIllegalArgumentException.- Parameters:
asserted- the assertion resultmessage- the error message- Throws:
IllegalArgumentException- ifassertedis false
-
assertionNullPointer
public static void assertionNullPointer(boolean asserted, String message)Asserts that the given parameter is true, otherwise throws anNullPointerException.- Parameters:
asserted- the assertion resultmessage- the error message- Throws:
NullPointerException- ifassertedis false
-
assertLegal
public static void assertLegal(Object underAssertion, String message)
Asserts that the given parameter is not null, otherwise throws anIllegalArgumentException.- Parameters:
underAssertion- the object to checkmessage- the error message- Throws:
IllegalArgumentException- ifassertedis null
-
assertNotNull
public static void assertNotNull(Object underAssertion, String message)
Asserts that the given parameter is not null, otherwise throws anNullPointerException.- Parameters:
underAssertion- the object to checkmessage- the error message- Throws:
NullPointerException- ifassertedis null
-
-