public class SourceException extends RuntimeException
Constructor and Description |
---|
SourceException(StatementSourceReference source,
String format,
Object... args)
Create a new instance with the specified source and a formatted message.
|
SourceException(StatementSourceReference source,
Throwable cause,
String format,
Object... args)
Create a new instance with the specified source and a formatted message.
|
SourceException(String message,
StatementSourceReference source)
Create a new instance with the specified message and source.
|
SourceException(String message,
StatementSourceReference source,
Throwable cause)
Create a new instance with the specified message and source.
|
Modifier and Type | Method and Description |
---|---|
StatementSourceReference |
getSourceReference()
Return the reference to the source which caused this exception.
|
static void |
throwIf(boolean expression,
StatementSourceReference source,
String format,
Object... args)
Throw an instance of this exception if an expression evaluates to true.
|
static <T> T |
throwIfNull(T obj,
StatementSourceReference source,
String format,
Object... args)
Throw an instance of this exception if an object is null.
|
static <T> T |
unwrap(Optional<T> opt,
StatementSourceReference source,
String format,
Object... args)
Throw an instance of this exception if an optional is not present.
|
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
public SourceException(@Nonnull String message, @Nonnull StatementSourceReference source)
message
- Context messagesource
- Statement sourcepublic SourceException(@Nonnull String message, @Nonnull StatementSourceReference source, Throwable cause)
message
- Context messagesource
- Statement sourcecause
- Underlying cause of this exceptionpublic SourceException(@Nonnull StatementSourceReference source, @Nonnull String format, Object... args)
source
- Statement sourceformat
- Format string, according to String.format(String, Object...)
.args
- Format string arguments, according to String.format(String, Object...)
public SourceException(@Nonnull StatementSourceReference source, Throwable cause, @Nonnull String format, Object... args)
source
- Statement sourcecause
- Underlying cause of this exceptionformat
- Format string, according to String.format(String, Object...)
.args
- Format string arguments, according to String.format(String, Object...)
@Nonnull public StatementSourceReference getSourceReference()
public static void throwIf(boolean expression, @Nonnull StatementSourceReference source, @Nonnull String format, Object... args)
expression
- Expression to be evaluatedsource
- Statement source referenceformat
- Format string, according to String.format(String, Object...)
.args
- Format string arguments, according to String.format(String, Object...)
SourceException
- if the expression evaluates to true.@Nonnull public static <T> T throwIfNull(@Nullable T obj, @Nonnull StatementSourceReference source, @Nonnull String format, Object... args)
obj
- Object reference to be checkedsource
- Statement source referenceformat
- Format string, according to String.format(String, Object...)
.args
- Format string arguments, according to String.format(String, Object...)
SourceException
- if object is null@Nonnull public static <T> T unwrap(Optional<T> opt, @Nonnull StatementSourceReference source, @Nonnull String format, Object... args)
opt
- Optional to be checkedsource
- Statement source referenceformat
- Format string, according to String.format(String, Object...)
.args
- Format string arguments, according to String.format(String, Object...)
SourceException
- if the optional is not presentCopyright © 2019 OpenDaylight. All rights reserved.