Package util.safety
Class Preconditions
java.lang.Object
util.safety.Preconditions
- Since:
- 18.06.2021
- Author:
- Juyas
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
ensureMainThread
(String location) Test if the current call is executed in the main thread.static <T> T
Improve code stability by doing non-null checks inline.static <T> T
nonNull
(T obj) Improve code stability by doing non-null checks inline.
-
Constructor Details
-
Preconditions
public Preconditions()
-
-
Method Details
-
ensureMainThread
Test if the current call is executed in the main thread. This is especially necessary if you run a mac, since mac doesnt like OpenGl calls in ANY thread except the first one. This method does NOT provide a valid exception if the whole program wasnt launched with VM argument -XstartOnFirstThread, because only with this argument, its guaranteed that the main thread is actually is the first. -
nonNull
public static <T> T nonNull(T obj) Improve code stability by doing non-null checks inline.- Type Parameters:
T
- any type- Parameters:
obj
- any object expected to be non-null- Returns:
- the object, if and only if its not null. throws a
NullPointerException
otherwise.
-
nonNull
Improve code stability by doing non-null checks inline.- Type Parameters:
T
- any type- Parameters:
obj
- any object expected to be non-nullname
- the name of the object to improve locating process- Returns:
- the object, if and only if its not null. throws a
NullPointerException
otherwise.
-