Top Description Constructors Methods
org.conscrypt

pack-priv final Class Preconditions

extends Object
Class Inheritance

Static convenience methods that help a method or constructor check whether it was invoked correctly (that is, whether its preconditions were met).

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private static String
badPositionIndex(int index, int size, String desc)

private static String
badPositionIndexes(int start, int end, int size)

pack-priv static void
checkArgument(boolean
to condition to be tested
condition
,
String
the exception message to use if the check fails.
errorMessage
)

Ensures the truth of an expression involving one or more parameters to the calling method.

pack-priv static void
checkArgument(boolean
to condition to be tested
condition
,
String
the format string to be passed to String#format(String, Object...)
errorMessageTemplate
,
Object
the format argument to be passed to String#format(String, Object...)
arg
)

Ensures the truth of an expression involving one or more parameters to the calling method.

pack-priv static <T> T

Returns:

the non-null reference that was validated
checkNotNull
(T
an object reference
reference
,
String
the exception message to use if the check fails.
errorMessage
)

Ensures that an object reference passed as a parameter to the calling method is not null.

pack-priv static void
checkPositionIndexes(int
a user-supplied index identifying a starting position in an array, list or string
start
,
int
a user-supplied index identifying a ending position in an array, list or string
end
,
int
the size of that array, list or string
size
)

Ensures that start and end specify a valid positions in an array, list or string of size size, and are in order.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

Preconditionsback to summary
private Preconditions()

Method Detail

badPositionIndexback to summary
private static String badPositionIndex(int index, int size, String desc)
badPositionIndexesback to summary
private static String badPositionIndexes(int start, int end, int size)
checkArgumentback to summary
pack-priv static void checkArgument(boolean condition, String errorMessage)

Ensures the truth of an expression involving one or more parameters to the calling method.

Parameters
condition:boolean

to condition to be tested

errorMessage:String

the exception message to use if the check fails.

Exceptions
IllegalArgumentException:
if the condition is false
checkArgumentback to summary
pack-priv static void checkArgument(boolean condition, String errorMessageTemplate, Object arg)

Ensures the truth of an expression involving one or more parameters to the calling method.

Parameters
condition:boolean

to condition to be tested

errorMessageTemplate:String

the format string to be passed to String#format(String, Object...)

arg:Object

the format argument to be passed to String#format(String, Object...)

Exceptions
IllegalArgumentException:
if the condition is false
checkNotNullback to summary
pack-priv static <T> T checkNotNull(T reference, String errorMessage)

Ensures that an object reference passed as a parameter to the calling method is not null.

Parameters
reference:T

an object reference

errorMessage:String

the exception message to use if the check fails.

Returns:T

the non-null reference that was validated

Exceptions
NullPointerException:
if reference is null
checkPositionIndexesback to summary
pack-priv static void checkPositionIndexes(int start, int end, int size)

Ensures that start and end specify a valid positions in an array, list or string of size size, and are in order. A position index may range from zero to size, inclusive.

Parameters
start:int

a user-supplied index identifying a starting position in an array, list or string

end:int

a user-supplied index identifying a ending position in an array, list or string

size:int

the size of that array, list or string

Exceptions
IndexOutOfBoundsException:
if either index is negative or is greater than size, or if end is less than start
IllegalArgumentException:
if size is negative