org.apache.ignite.internal.util

## Class GridArgumentCheck

- java.lang.Object
- - org.apache.ignite.internal.util.GridArgumentCheck

Direct Known Subclasses:
  A

    public class GridArgumentCheck
    extends Object

This class encapsulates argument check (null and range) for public facing APIs. Unlike asserts it throws "normal" exceptions with standardized messages.

### Field Summary

Fields
`static String` `NULL_MSG_PREFIX` Null pointer error message prefix.

### Constructor Summary

Constructors
Constructor and Description
`GridArgumentCheck()`

### Method Summary

All Methods Static Methods Concrete Methods
`static void` `ensure(boolean cond, String desc)` Checks if given argument's condition is equal to `true`, otherwise throws `IllegalArgumentException` exception.
`static void` `notEmpty(Collection<?> c, String name)` Checks that given collection is not empty.
`static void` `notEmpty(double[] arr, String name)` Checks that given array is not empty.
`static void` `notEmpty(int[] arr, String name)` Checks that given array is not empty.
`static void` `notEmpty(long[] arr, String name)` Checks that given array is not empty.
`static void` `notEmpty(Object[] arr, String name)` Checks that given array is not empty.
`static void` `notNull(@Nullable Object val, String name)` Checks if given argument value is not `null`.
`static void` `notNull(Object val1, String name1, Object val2, String name2)` Checks that none of the given values are `null`.
`static void` `notNull(Object val1, String name1, Object val2, String name2, Object val3, String name3)` Checks that none of the given values are `null`.
`static void` `notNull(Object val1, String name1, Object val2, String name2, Object val3, String name3, Object val4, String name4)` Checks that none of the given values are `null`.
`static void` `notNullOrEmpty(String value, String name)` Checks that a String is not null or empty.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### NULL_MSG_PREFIX

    public static final String NULL_MSG_PREFIX

Null pointer error message prefix.

See Also:
  Constant Field Values

### Constructor Detail

#### GridArgumentCheck

    public GridArgumentCheck()

### Method Detail

#### notNull

    public static void notNull(@Nullable
                               @Nullable Object val,
                               String name)

Checks if given argument value is not `null`. Otherwise - throws `NullPointerException`.

Parameters:
  `val` - Argument value to check.
  `name` - Name of the argument in the code (used in error message).

#### notNull

    public static void notNull(Object val1,
                               String name1,
                               Object val2,
                               String name2)

Checks that none of the given values are `null`. Otherwise - throws `NullPointerException`.

Parameters:
  `val1` - 1st argument value to check.
  `name1` - Name of the 1st argument in the code (used in error message).
  `val2` - 2nd argument value to check.
  `name2` - Name of the 2nd argument in the code (used in error message).

#### notNull

    public static void notNull(Object val1,
                               String name1,
                               Object val2,
                               String name2,
                               Object val3,
                               String name3)

Checks that none of the given values are `null`. Otherwise - throws `NullPointerException`.

Parameters:
  `val1` - 1st argument value to check.
  `name1` - Name of the 1st argument in the code (used in error message).
  `val2` - 2nd argument value to check.
  `name2` - Name of the 2nd argument in the code (used in error message).
  `val3` - 3rd argument value to check.
  `name3` - Name of the 3rd argument in the code (used in error message).

#### notNull

    public static void notNull(Object val1,
                               String name1,
                               Object val2,
                               String name2,
                               Object val3,
                               String name3,
                               Object val4,
                               String name4)

Checks that none of the given values are `null`. Otherwise - throws `NullPointerException`.

Parameters:
  `val1` - 1st argument value to check.
  `name1` - Name of the 1st argument in the code (used in error message).
  `val2` - 2nd argument value to check.
  `name2` - Name of the 2nd argument in the code (used in error message).
  `val3` - 3rd argument value to check.
  `name3` - Name of the 3rd argument in the code (used in error message).
  `val4` - 4th argument value to check.
  `name4` - Name of the 4th argument in the code (used in error message).

#### ensure

    public static void ensure(boolean cond,
                              String desc)

Checks if given argument's condition is equal to `true`, otherwise throws `IllegalArgumentException` exception.

Parameters:
  `cond` - Argument's value condition to check.
  `desc` - Description of the condition to be used in error message.

#### notEmpty

    public static void notEmpty(Collection<?> c,
                                String name)

Checks that given collection is not empty.

Parameters:
  `c` - Collection.
  `name` - Argument name.

#### notEmpty

    public static void notEmpty(Object[] arr,
                                String name)

Checks that given array is not empty.

Parameters:
  `arr` - Array.
  `name` - Argument name.

#### notEmpty

    public static void notEmpty(int[] arr,
                                String name)

Checks that given array is not empty.

Parameters:
  `arr` - Array.
  `name` - Argument name.

#### notEmpty

    public static void notEmpty(long[] arr,
                                String name)

Checks that given array is not empty.

Parameters:
  `arr` - Array.
  `name` - Argument name.

#### notEmpty

    public static void notEmpty(double[] arr,
                                String name)

Checks that given array is not empty.

Parameters:
  `arr` - Array.
  `name` - Argument name.

#### notNullOrEmpty

    public static void notNullOrEmpty(String value,
                                      String name)

Checks that a String is not null or empty.

Parameters:
  `value` - Value to check.
  `name` - Argument name.

${current.year} Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Database and Caching Platform | : ver. 2.9.1
Release Date | : December 9 2020