public class LoggingPreconditions extends Object
Constructor and Description |
---|
LoggingPreconditions(org.slf4j.Logger logger) |
Modifier and Type | Method and Description |
---|---|
void |
checkArgument(boolean expression,
String errorMessage,
Object... messageParams) |
void |
checkNotNull(Object o,
String errorMessage,
Object... messageParams) |
void |
checkState(boolean expression,
String errorMessage,
Object... messageParams) |
void |
logAndThrow(Function<String,RuntimeException> exceptionCreator,
String errorMessage,
Object... messageParams)
Formats an error message with parameters using
String.format , logs it using logger ,
and throws an unchecked exception with the same message created by exceptionCreator . |
<T> T |
wrapInUnchecked(Exception exception,
BiFunction<String,Exception,RuntimeException> uncheckedWrapper,
String errorMessage,
Object... messageParams)
Wraps
exception in an unchecked exception created by uncheckedWrapper , and always throws the unchecked exception. |
public void checkArgument(boolean expression, String errorMessage, Object... messageParams)
public <T> T wrapInUnchecked(Exception exception, BiFunction<String,Exception,RuntimeException> uncheckedWrapper, String errorMessage, Object... messageParams)
exception
in an unchecked exception created by uncheckedWrapper
, and always throws the unchecked exception.public void logAndThrow(Function<String,RuntimeException> exceptionCreator, String errorMessage, Object... messageParams)
String.format
, logs it using logger
,
and throws an unchecked exception with the same message created by exceptionCreator
.Copyright © 2022 Apache Software Foundation. All rights reserved.