Class AssertionUtil


  • public final class AssertionUtil
    extends Object
    • Method Detail

      • isAssertEnabled

        public static boolean isAssertEnabled()
        Return true if the VM runs with assertions enabled.
      • isValidJavaPackageName

        public static boolean isValidJavaPackageName​(CharSequence name)
      • validateState

        public static void validateState​(boolean condition,
                                         String failed)
        Throws IllegalStateException if the condition is false.
      • validateStringRange

        public static void validateStringRange​(CharSequence string,
                                               int startInclusive,
                                               int endExclusive)
        Throws:
        IllegalArgumentException - if [startInclusive,endExclusive[ is not a valid substring range for the given string
      • isJavaIdentifier

        public static boolean isJavaIdentifier​(CharSequence name)
        Returns true if the charsequence is a valid java identifier.
        Parameters:
        name - Name (non-null)
        Throws:
        NullPointerException - If the name is null
      • requireOver1

        public static int requireOver1​(String name,
                                       int value)
      • requireInNonNegativeRange

        public static int requireInNonNegativeRange​(String name,
                                                    int value,
                                                    int maxValue)
        Throws:
        IndexOutOfBoundsException - If value < 0 || value >= maxValue
      • requireInPositiveRange

        public static int requireInPositiveRange​(String name,
                                                 int value,
                                                 int maxValue)
        Throws:
        IndexOutOfBoundsException - If value < 1 || value >= maxValue
      • requireInInclusiveRange

        public static int requireInInclusiveRange​(String name,
                                                  int value,
                                                  int minValue,
                                                  int maxValue)
        Throws:
        IndexOutOfBoundsException - If value < minValue || value > maxValue
      • requireInExclusiveRange

        public static int requireInExclusiveRange​(String name,
                                                  int value,
                                                  int minValue,
                                                  int maxValue)
        Throws:
        IndexOutOfBoundsException - If value < minValue || value > maxValue
      • requireInRange

        public static int requireInRange​(String name,
                                         int value,
                                         int minValue,
                                         int maxValue,
                                         boolean inclusive)
      • requireParamNotNull

        public static <T> @NonNull T requireParamNotNull​(String paramName,
                                                         T obj)
      • contexted

        public static @NonNull org.apache.commons.lang3.exception.ContextedRuntimeException contexted​(RuntimeException e)