Class Assumed


  • public final class Assumed
    extends Object

    Some utility classes to check parameter

    Since:
    1.0
    Version:
    1.0 $Revision: 7681 $
    Author:
    "Martin Krischik" «krischik@users.sourceforge.net»
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static Logger Logger
      Class logger instance.
      private static String TAG
      Class logger tag.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private Assumed()
      Utility class, do not create
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void equal​(long left, long right)
      test if a string lengths is inside the range min … max
      static void equal​(long left, long right, @NotNull String name)
      test if a string lengths is inside the range min … max
      static void equal​(@NotNull Enum<?> left, @NotNull Enum<?> right, @NotNull String name)
      test if two enums are the same.
      static void greaterEqual​(long left, long right)
      test if a string lengths is inside the range min … max
      static void greaterEqual​(long left, long right, @NotNull String name)
      test if a string lengths is inside the range min … max
      static void isFalse​(boolean value)
      test if a string lengths is inside the range min … max
      static void isFalse​(boolean value, @NotNull String name)
      test if a string lengths is inside the range min … max
      static void isInstance​(@NotNull Object value, @NotNull Class<?> type)
      test if a string lengths is inside the range min … max
      static void isInstance​(@NotNull Object value, @NotNull Class<?> type, @NotNull String name)
      test if a string lengths is inside the range min … max
      static void isNatural​(int value)
      test if a numeric value is greater or equal 0
      static void isNatural​(int value, @NotNull String name)
      test if a numeric value is greater or equal 0
      static void isNull​(@Nullable Object value)
      test if an instance is null
      static void isNull​(@Nullable Object value, @NotNull String name)
      test if an instance is null
      static void isPositive​(int value)
      test if a numeric value is greater or equal 1
      static void isPositive​(int value, @NotNull String name)
      test if a numeric value is greater or equal 1
      static void isTrue​(boolean value)
      test if a string lengths is inside the range min … max
      static void isTrue​(boolean value, @NotNull String name)
      test if a string lengths is inside the range min … max
      static void notEmpty​(@Nullable String value)
      test if a string lengths is not empty
      static void notEmpty​(@Nullable String value, @NotNull String name)
      test if a string lengths is not empty
      static void notNull​(@Nullable Object value)
      test if an instnce is not null
      static void notNull​(@Nullable Object value, @NotNull String name)
      test if an instnce is not null
      static void range​(byte value, byte min, byte max)
      test if a numeric value is inside the range min … max
      static void range​(byte value, byte min, byte max, @NotNull String name)
      test if a numeric value is inside the range min … max
      static void range​(double value, double min, double max)
      test if a numeric value is inside the range min … max
      static void range​(double value, double min, double max, @NotNull String name)
      test if a numeric value is inside the range min … max
      static void range​(float value, float min, float max)
      test if a numeric value is inside the range min … max
      static void range​(float value, float min, float max, @NotNull String name)
      test if a numeric value is inside the range min … max
      static void range​(int value, int min, int max)
      test if a numeric value is inside the range min … max
      static void range​(int value, int min, int max, @NotNull String name)
      test if a numeric value is inside the range min … max
      static void range​(long value, long min, long max)
      test if a numeric value is inside the range min … max
      static void range​(long value, long min, long max, @NotNull String name)
      test if a numeric value is inside the range min … max
      static void range​(short value, short min, short max)
      test if a numeric value is inside the range min … max
      static void range​(short value, short min, short max, @NotNull String name)
      test if a numeric value is inside the range min … max
      static void range​(@NotNull CharSequence value, int min, int max)
      test if a string lenght is inside the range min … max
      static void range​(@NotNull CharSequence value, int min, int max, @NotNull String name)
      test if a string length is inside the range min … max
      static void range​(@NotNull Object @NotNull [] value, int min, int max)
      test if a string length is inside the range min … max
      static void range​(@NotNull Object @NotNull [] value, int min, int max, @NotNull String name)
      test if a string lenght is inside the range min … max
      static void rangeOrNull​(@Nullable CharSequence value, int min, int max)
      test if a string length is inside the range min … max
      static void rangeOrNull​(@Nullable CharSequence value, int min, int max, @NotNull String name)
      test if a string length is inside the range min … max
    • Field Detail

      • Logger

        private static final Logger Logger

        Class logger instance.

      • TAG

        private static final String TAG

        Class logger tag.

    • Constructor Detail

      • Assumed

        private Assumed()

        Utility class, do not create

    • Method Detail

      • equal

        public static void equal​(long left,
                                 long right)

        test if a string lengths is inside the range min … max

        Parameters:
        left - value to test
        right - value to test
        Throws:
        IllegalStateException - when value is outside min … max
      • equal

        public static void equal​(long left,
                                 long right,
                                 @NotNull
                                 @NotNull String name)

        test if a string lengths is inside the range min … max

        Parameters:
        left - value to test
        right - value to test
        name - value name for better error message
        Throws:
        IllegalStateException - when value is outside min … max
      • equal

        public static void equal​(@NotNull
                                 @NotNull Enum<?> left,
                                 @NotNull
                                 @NotNull Enum<?> right,
                                 @NotNull
                                 @NotNull String name)

        test if two enums are the same.

        Parameters:
        left - value to test
        right - value to test
        name - value name for better error message
        Throws:
        IllegalStateException - when value is outside min … max
      • greaterEqual

        public static void greaterEqual​(long left,
                                        long right)

        test if a string lengths is inside the range min … max

        Parameters:
        left - value to test
        right - value to test
        Throws:
        IllegalStateException - when value is outside min … max
      • greaterEqual

        public static void greaterEqual​(long left,
                                        long right,
                                        @NotNull
                                        @NotNull String name)

        test if a string lengths is inside the range min … max

        Parameters:
        left - value to test
        right - value to test
        name - value name for better error message
        Throws:
        IllegalStateException - when value is outside min … max
      • isFalse

        @Contract("true -> fail")
        public static void isFalse​(boolean value)

        test if a string lengths is inside the range min … max

        Parameters:
        value - value to test
        Throws:
        IllegalStateException - when value is outside min … max
      • isFalse

        @Contract("true, _ -> fail")
        public static void isFalse​(boolean value,
                                   @NotNull
                                   @NotNull String name)

        test if a string lengths is inside the range min … max

        Parameters:
        value - value to test
        name - value name for better error message
        Throws:
        IllegalStateException - when value is outside min … max
      • isInstance

        public static void isInstance​(@NotNull
                                      @NotNull Object value,
                                      @NotNull
                                      @NotNull Class<?> type)

        test if a string lengths is inside the range min … max

        Parameters:
        value - value to test
        type - type to check against
        Throws:
        IllegalStateException - when value is outside min … max
      • isInstance

        public static void isInstance​(@NotNull
                                      @NotNull Object value,
                                      @NotNull
                                      @NotNull Class<?> type,
                                      @NotNull
                                      @NotNull String name)

        test if a string lengths is inside the range min … max

        Parameters:
        value - value to test
        type - type to check against
        name - value name for better error message
        Throws:
        IllegalStateException - when value is outside min … max
      • isNatural

        public static void isNatural​(int value)

        test if a numeric value is greater or equal 0

        Parameters:
        value - value to test
        Throws:
        IllegalArgumentException - when value is not not greater 0
      • isNatural

        public static void isNatural​(int value,
                                     @NotNull
                                     @NotNull String name)

        test if a numeric value is greater or equal 0

        Parameters:
        value - value to test
        name - value name for better error message
        Throws:
        IllegalArgumentException - when value is not greater or equal 0
      • isNull

        @Contract("!null -> fail")
        public static void isNull​(@Nullable
                                  @Nullable Object value)

        test if an instance is null

        Parameters:
        value - value to test
        Throws:
        IllegalStateException - when the instance is null
      • isNull

        @Contract("!null, _ -> fail")
        public static void isNull​(@Nullable
                                  @Nullable Object value,
                                  @NotNull
                                  @NotNull String name)

        test if an instance is null

        Parameters:
        value - value to test
        name - value name for better error message
        Throws:
        IllegalStateException - when the instance is null
      • isPositive

        public static void isPositive​(int value)

        test if a numeric value is greater or equal 1

        Parameters:
        value - value to test
        Throws:
        IllegalArgumentException - when value is not greater or equal 1
      • isPositive

        public static void isPositive​(int value,
                                      @NotNull
                                      @NotNull String name)

        test if a numeric value is greater or equal 1

        Parameters:
        value - value to test
        name - value name for better error message
        Throws:
        IllegalArgumentException - when value is not greater or equal 1
      • isTrue

        @Contract("false -> fail")
        public static void isTrue​(boolean value)

        test if a string lengths is inside the range min … max

        Parameters:
        value - value to test
        Throws:
        IllegalStateException - when value is outside min … max
      • isTrue

        @Contract("false, _ -> fail")
        public static void isTrue​(boolean value,
                                  @NotNull
                                  @NotNull String name)

        test if a string lengths is inside the range min … max

        Parameters:
        value - value to test
        name - value name for better error message
        Throws:
        IllegalStateException - when value is outside min … max
      • notEmpty

        public static void notEmpty​(@Nullable
                                    @Nullable String value)

        test if a string lengths is not empty

        Parameters:
        value - value to test
        Throws:
        IllegalStateException - when value is outside min … max
      • notEmpty

        public static void notEmpty​(@Nullable
                                    @Nullable String value,
                                    @NotNull
                                    @NotNull String name)

        test if a string lengths is not empty

        Parameters:
        value - value to test
        name - value name for better error message
        Throws:
        IllegalStateException - when value is outside min … max
      • notNull

        @Contract("null -> fail")
        public static void notNull​(@Nullable
                                   @Nullable Object value)

        test if an instnce is not null

        Parameters:
        value - value to test
        Throws:
        IllegalStateException - when the instance is null
      • notNull

        @Contract("null, _ -> fail")
        public static void notNull​(@Nullable
                                   @Nullable Object value,
                                   @NotNull
                                   @NotNull String name)

        test if an instnce is not null

        Parameters:
        value - value to test
        name - value name for better error message
        Throws:
        IllegalStateException - when the instance is null
      • range

        public static void range​(byte value,
                                 byte min,
                                 byte max)

        test if a numeric value is inside the range min … max

        Parameters:
        value - value to test
        min - minimum allowed value
        max - maximum allowed value
        Throws:
        IllegalStateException - when value is outside min … max
      • range

        public static void range​(byte value,
                                 byte min,
                                 byte max,
                                 @NotNull
                                 @NotNull String name)

        test if a numeric value is inside the range min … max

        Parameters:
        value - value to test
        min - minimum allowed value
        max - maximum allowed value
        name - value name for better error message
        Throws:
        IllegalStateException - when value is outside min … max
      • range

        public static void range​(@NotNull
                                 @NotNull CharSequence value,
                                 int min,
                                 int max)

        test if a string lenght is inside the range min … max

        Parameters:
        value - value to test
        min - minimum allowed value
        max - maximum allowed value
        Throws:
        IllegalStateException - when value is outside min … max
      • range

        public static void range​(@NotNull
                                 @NotNull CharSequence value,
                                 int min,
                                 int max,
                                 @NotNull
                                 @NotNull String name)

        test if a string length is inside the range min … max

        Parameters:
        value - value to test
        min - minimum allowed value
        max - maximum allowed value
        name - value name for better error message
        Throws:
        IllegalStateException - when value is outside min … max
      • range

        public static void range​(double value,
                                 double min,
                                 double max)

        test if a numeric value is inside the range min … max

        Parameters:
        value - value to test
        min - minimum allowed value
        max - maximum allowed value
        Throws:
        IllegalStateException - when value is outside min … max
      • range

        public static void range​(double value,
                                 double min,
                                 double max,
                                 @NotNull
                                 @NotNull String name)

        test if a numeric value is inside the range min … max

        Parameters:
        value - value to test
        min - minimum allowed value
        max - maximum allowed value
        name - value name for better error message
        Throws:
        IllegalStateException - when value is outside min … max
      • range

        public static void range​(float value,
                                 float min,
                                 float max)

        test if a numeric value is inside the range min … max

        Parameters:
        value - value to test
        min - minimum allowed value
        max - maximum allowed value
        Throws:
        IllegalStateException - when value is outside min … max
      • range

        public static void range​(float value,
                                 float min,
                                 float max,
                                 @NotNull
                                 @NotNull String name)

        test if a numeric value is inside the range min … max

        Parameters:
        value - value to test
        min - minimum allowed value
        max - maximum allowed value
        name - value name for better error message
        Throws:
        IllegalStateException - when value is outside min … max
      • range

        public static void range​(int value,
                                 int min,
                                 int max)

        test if a numeric value is inside the range min … max

        Parameters:
        value - value to test
        min - minimum allowed value
        max - maximum allowed value
        Throws:
        IllegalStateException - when value is outside min … max
      • range

        public static void range​(int value,
                                 int min,
                                 int max,
                                 @NotNull
                                 @NotNull String name)

        test if a numeric value is inside the range min … max

        Parameters:
        value - value to test
        min - minimum allowed value
        max - maximum allowed value
        name - value name for better error message
        Throws:
        IllegalStateException - when value is outside min … max
      • range

        public static void range​(long value,
                                 long min,
                                 long max)

        test if a numeric value is inside the range min … max

        Parameters:
        value - value to test
        min - minimum allowed value
        max - maximum allowed value
        Throws:
        IllegalStateException - when value is outside min … max
      • range

        public static void range​(long value,
                                 long min,
                                 long max,
                                 @NotNull
                                 @NotNull String name)

        test if a numeric value is inside the range min … max

        Parameters:
        value - value to test
        min - minimum allowed value
        max - maximum allowed value
        name - value name for better error message
        Throws:
        IllegalStateException - when value is outside min … max
      • range

        public static void range​(@NotNull
                                 @NotNull Object @NotNull [] value,
                                 int min,
                                 int max)

        test if a string length is inside the range min … max

        Parameters:
        value - value to test
        min - minimum allowed value
        max - maximum allowed value
        Throws:
        IllegalStateException - when value is outside min … max
      • range

        public static void range​(@NotNull
                                 @NotNull Object @NotNull [] value,
                                 int min,
                                 int max,
                                 @NotNull
                                 @NotNull String name)

        test if a string lenght is inside the range min … max

        Parameters:
        value - value to test
        min - minimum allowed value
        max - maximum allowed value
        name - value name for better error message
        Throws:
        IllegalStateException - when value is outside min … max
      • range

        public static void range​(short value,
                                 short min,
                                 short max)

        test if a numeric value is inside the range min … max

        Parameters:
        value - value to test
        min - minimum allowed value
        max - maximum allowed value
        Throws:
        IllegalStateException - when value is outside min … max
      • range

        public static void range​(short value,
                                 short min,
                                 short max,
                                 @NotNull
                                 @NotNull String name)

        test if a numeric value is inside the range min … max

        Parameters:
        value - value to test
        min - minimum allowed value
        max - maximum allowed value
        name - value name for better error message
        Throws:
        IllegalStateException - when value is outside min … max
      • rangeOrNull

        public static void rangeOrNull​(@Nullable
                                       @Nullable CharSequence value,
                                       int min,
                                       int max)

        test if a string length is inside the range min … max

        Parameters:
        value - value to test
        min - minimum allowed value
        max - maximum allowed value
        Throws:
        IllegalStateException - when value is outside min … max
      • rangeOrNull

        public static void rangeOrNull​(@Nullable
                                       @Nullable CharSequence value,
                                       int min,
                                       int max,
                                       @NotNull
                                       @NotNull String name)

        test if a string length is inside the range min … max

        Parameters:
        value - value to test
        min - minimum allowed value
        max - maximum allowed value
        name - value name for better error message
        Throws:
        IllegalStateException - when value is outside min … max