Top Description Constructors Methods
com.ongres.scram.common.util

public Class Preconditions

extends Object
Class Inheritance

Simple methods similar to Precondition class. Avoid importing full library.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static void
checkArgument(boolean
The boolean check
check
,
String
The name of the value that is checked in the method
valueName
)

Checks that the argument is valid, based in a check boolean condition.

public static String

Returns:

The same String passed as argument
checkNotEmpty
(String
The String to check
value
,
String
The name of the value that is checked in the method
valueName
)

Checks that the String is not null and not empty

public static <
The type of the value
T
>
T

Returns:

The same value passed as argument
checkNotNull
(T
The value to be checked
value
,
String
The name of the value that is checked in the method
valueName
)

Checks that the argument is not null.

public static int

Returns:

The same value passed as argument
gt0
(int
The value to be checked
value
,
String
The name of the value that is checked in the method
valueName
)

Checks that the integer argument is positive.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

Preconditionsback to summary
public Preconditions()

Method Detail

checkArgumentback to summary
public static void checkArgument(boolean check, String valueName) throws IllegalArgumentException

Checks that the argument is valid, based in a check boolean condition.

Parameters
check:boolean

The boolean check

valueName:String

The name of the value that is checked in the method

checkNotEmptyback to summary
public static String checkNotEmpty(String value, String valueName) throws IllegalArgumentException

Checks that the String is not null and not empty

Parameters
value:String

The String to check

valueName:String

The name of the value that is checked in the method

Returns:String

The same String passed as argument

Exceptions
IllegalArgumentException:
If value is null or empty
checkNotNullback to summary
public static <T> T checkNotNull(T value, String valueName) throws IllegalArgumentException

Checks that the argument is not null.

Parameters
<T>
The type of the value
value:T

The value to be checked

valueName:String

The name of the value that is checked in the method

Returns:T

The same value passed as argument

Exceptions
IllegalArgumentException:
If value is null
gt0back to summary
public static int gt0(int value, String valueName) throws IllegalArgumentException

Checks that the integer argument is positive.

Parameters
value:int

The value to be checked

valueName:String

The name of the value that is checked in the method

Returns:int

The same value passed as argument

Exceptions
IllegalArgumentException:
If value is null