Conditions

  
Type🔵 Class
Packageio.github.mrtesz.teszcore.util
GitHubConditions.java

Description

Utility class for validating arguments, states, and values. Throws descriptive exceptions when conditions are not met, similar to Guava’s Preconditions.


Methods

checkArgument

static void checkArgument(boolean argument) throws IllegalArgumentException;
static void checkArgument(boolean argument, String message) throws IllegalArgumentException;

Check a boolean and throw an exception if argument is false

ParameterTypeAnnotationsDescription
argumentboolean-Argument
messageString@NullableMessage in the exception, if thrown

Throws: IllegalArgumentException when argument is false


checkRange

static <T extends Number> T checkRange(T num, T min, T max) throws IllegalNumberRangeException;
static <T extends Number> T checkRange(T num, T min, T max, String message) throws IllegalNumberRangeException;

Check if a number is in a range and throw an exception if it’s not

ParameterTypeAnnotationsDescription
numT-Number to check
minT-Range minimum
maxT-Range maximum
messageString@NullableMessage in the exception, if thrown

Returns: T - num

Throws: IllegalNumberRangeException when num is not in the provided range


checkState

static void checkState(boolean state) throws IllegalStateException;
static void checkState(boolean state, String message) throws IllegalStateException;

Check a boolean and throw an exception if it is false

ParameterTypeAnnotationsDescription
stateboolean-State
messageString@NullableMessage in the exception, if thrown

Throws: IllegalStateException when state is false


checkNonNull

static <T> T checkNonNull(T obj) throws NullPointerException;
static <T> T checkNonNull(T obj, String message) throws NullPointerException;

Check if an object not null

ParameterTypeAnnotationsDescription
objboolean-Object
messageString@NullableMessage in the exception, if thrown

Returns: T - obj

Throws: NullPointerException when obj is null


checkNull

static <T> void checkNull(T obj) throws NotNullException;
static <T> void checkNull(T obj, String message) throws NotNullException;

Check if an object is not null

ParameterTypeAnnotationsDescription
objboolean-Object
messageString@NullableMessage in the exception, if thrown

Throws: NotNullException when obj is not null



Back to top

Copyright © 2026 Mr_Tesz. All rights reserved

This site uses Just the Docs, a documentation theme for Jekyll.