public class SourceException extends RuntimeException
Constructor and Description |
---|
SourceException(@NonNull StatementSourceReference source,
@NonNull String format,
Object... args)
Create a new instance with the specified source and a formatted message.
|
SourceException(@NonNull StatementSourceReference source,
Throwable cause,
@NonNull String format,
Object... args)
Create a new instance with the specified source and a formatted message.
|
SourceException(@NonNull String message,
@NonNull StatementSourceReference source)
Create a new instance with the specified message and source.
|
SourceException(@NonNull String message,
@NonNull StatementSourceReference source,
Throwable cause)
Create a new instance with the specified message and source.
|
Modifier and Type | Method and Description |
---|---|
@NonNull StatementSourceReference |
getSourceReference()
Return the reference to the source which caused this exception.
|
static void |
throwIf(boolean expression,
@NonNull StatementSourceReference source,
@NonNull String format,
Object... args)
Throw an instance of this exception if an expression evaluates to true.
|
static <T> T |
throwIfNull(T obj,
@NonNull StatementSourceReference source,
@NonNull String format,
Object... args)
Throw an instance of this exception if an object is null.
|
static <T> T |
unwrap(Optional<T> opt,
@NonNull StatementSourceReference source,
@NonNull 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...)
public @NonNull 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.public static <T> T throwIfNull(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 nullpublic 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.