Package org.semanticweb.owlapi.util
Class OWLAPIPreconditions
java.lang.Object
org.semanticweb.owlapi.util.OWLAPIPreconditions
A set of personalized preconditions.
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
checkIterableNotNull
(Object[] o, String name, boolean emptyAllowed) static void
checkIterableNotNull
(Collection<?> o, String name, boolean emptyAllowed) static void
checkNotNegative
(long object) Check for negative value and throw IllegalArgumentException if negative.static void
checkNotNegative
(long object, String message) Check for negative value and throw IllegalArgumentException if negative.static void
checkNotNegative
(long object, Supplier<String> message) Check for negative value and throw IllegalArgumentException if negative.static <T> T
checkNotNull
(Optional<T> object, String message) Deprecated.static <T> T
checkNotNull
(Optional<T> object, Supplier<String> message) Check for absent and throw IllegalArgumentException if null or absent.static <T> T
checkNotNull
(T object) Check for null and throw NullPointerException if null.static <T> T
checkNotNull
(T object, String message) Check for null and throw NullPointerException if null.static <T> T
checkNotNull
(T object, Supplier<String> message) Check for null and throw NullPointerException if null.static <Q,
T extends Collection<Q>>
TcheckValidForNAryExpressions
(T object, String message) Check for null or empty and throw NullPointerException if null or empty.static <T> Optional<T>
Wrapper to allow non null annotations.static <T> Optional<T>
emptyOptional
(Class<T> t) Wrapper to allow non null annotations.static <T> Optional<T>
optional
(T t) Wrapper to allow non null annotations.static <T> T
verifyNotNull
(T object) Check that the argument is not null; if the argument is null, throw an IllegalStateException.static <T> T
verifyNotNull
(T object, String message) Check that the argument is not null; if the argument is null, throw an IllegalStateException.static <T> T
verifyNotNull
(T object, Supplier<String> message) Check that the argument is not null; if the argument is null, throw an IllegalStateException.
-
Method Details
-
verifyNotNull
Check that the argument is not null; if the argument is null, throw an IllegalStateException. This method is meant to be used to verify conditions on member variables rather than input parameters.- Type Parameters:
T
- reference type- Parameters:
object
- reference to check- Returns:
- the input reference if not null
- Throws:
IllegalStateException
- if object is null
-
verifyNotNull
Check that the argument is not null; if the argument is null, throw an IllegalStateException. This method is meant to be used to verify conditions on member variables rather than input parameters.- Type Parameters:
T
- reference type- Parameters:
object
- reference to checkmessage
- message to use for the error- Returns:
- the input reference if not null
- Throws:
IllegalStateException
- if object is null
-
verifyNotNull
Check that the argument is not null; if the argument is null, throw an IllegalStateException. This method is meant to be used to verify conditions on member variables rather than input parameters.- Type Parameters:
T
- reference type- Parameters:
object
- reference to checkmessage
- message to use for the error- Returns:
- the input reference if not null
- Throws:
IllegalStateException
- if object is null
-
checkNotNull
Check for null and throw NullPointerException if null.- Type Parameters:
T
- reference type- Parameters:
object
- reference to check- Returns:
- the input reference if not null
- Throws:
NullPointerException
- if object is null
-
checkNotNull
Check for null and throw NullPointerException if null.- Type Parameters:
T
- reference type- Parameters:
object
- reference to checkmessage
- message for the illegal argument exception- Returns:
- the input reference if not null
- Throws:
NullPointerException
- if object is null
-
checkValidForNAryExpressions
public static <Q,T extends Collection<Q>> T checkValidForNAryExpressions(@Nullable T object, String message) Check for null or empty and throw NullPointerException if null or empty.- Type Parameters:
T
- collection typeQ
- reference type- Parameters:
object
- reference to checkmessage
- message for the illegal argument exception- Returns:
- the input reference if not null
- Throws:
NullPointerException
- if object is null
-
checkNotNull
Check for null and throw NullPointerException if null.- Type Parameters:
T
- reference type- Parameters:
object
- reference to checkmessage
- message for the illegal argument exception- Returns:
- the input reference if not null
- Throws:
NullPointerException
- if object is null
-
checkNotNegative
Check for negative value and throw IllegalArgumentException if negative.- Parameters:
object
- value to check- Throws:
IllegalArgumentException
- if object is negative
-
checkNotNegative
Check for negative value and throw IllegalArgumentException if negative.- Parameters:
object
- value to checkmessage
- message for the illegal argument exception- Throws:
IllegalArgumentException
- if object is negative
-
checkNotNegative
Check for negative value and throw IllegalArgumentException if negative.- Parameters:
object
- value to checkmessage
- message for the illegal argument exception- Throws:
IllegalArgumentException
- if object is negative
-
checkNotNull
Deprecated.Check for absent and throw IllegalArgumentException if null or absent.- Type Parameters:
T
- reference type- Parameters:
object
- reference to checkmessage
- message for the illegal argument exception- Returns:
- the input reference if not null
- Throws:
IllegalArgumentException
- if object is null
-
checkNotNull
Check for absent and throw IllegalArgumentException if null or absent.- Type Parameters:
T
- reference type- Parameters:
object
- reference to checkmessage
- message for the illegal argument exception- Returns:
- the input reference if not null
- Throws:
IllegalArgumentException
- if object is null
-
checkIterableNotNull
public static void checkIterableNotNull(@Nullable Collection<?> o, String name, boolean emptyAllowed) - Parameters:
o
- collection to check for nullness and null elements, and optionally for emptinessname
- message for erroremptyAllowed
- true if the input can be empty
-
checkIterableNotNull
- Parameters:
o
- array to check for nullness and null elements, and optionally for emptinessname
- message for erroremptyAllowed
- true if the input can be empty
-
emptyOptional
Wrapper to allow non null annotations.- Type Parameters:
T
- type- Returns:
- empty optional instance
-
emptyOptional
Wrapper to allow non null annotations.- Type Parameters:
T
- type- Parameters:
t
- type for the returned optional- Returns:
- empty optional instance
-
optional
Wrapper to allow non null annotations.- Type Parameters:
T
- type- Parameters:
t
- instance to wrap. Can be null (the result will be Optional.empty())- Returns:
- optional instance (content can be absent)
-
checkNotNull(Object, Supplier)