Class SourceException

    • Constructor Detail

      • SourceException

        public SourceException​(@NonNull String message,
                               @NonNull StatementSourceReference source)
        Create a new instance with the specified message and source. The message will be appended with the source reference.
        Parameters:
        message - Context message
        source - Statement source
      • SourceException

        public SourceException​(@NonNull String message,
                               @NonNull StatementSourceReference source,
                               Throwable cause)
        Create a new instance with the specified message and source. The message will be appended with the source reference.
        Parameters:
        message - Context message
        source - Statement source
        cause - Underlying cause of this exception
    • Method Detail

      • getSourceReference

        public @NonNull StatementSourceReference getSourceReference()
        Return the reference to the source which caused this exception.
        Returns:
        Source reference
      • throwIf

        public 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. If the expression evaluates to false, this method does nothing.
        Parameters:
        expression - Expression to be evaluated
        source - Statement source reference
        format - Format string, according to String.format(String, Object...).
        args - Format string arguments, according to String.format(String, Object...)
        Throws:
        SourceException - if the expression evaluates to true.
      • throwIfNull

        public static <T> @NonNull T throwIfNull​(@Nullable T obj,
                                                 @NonNull StatementSourceReference source,
                                                 @NonNull String format,
                                                 Object... args)
        Throw an instance of this exception if an object is null. If the object is non-null, it will be returned as the result of this method.
        Parameters:
        obj - Object reference to be checked
        source - Statement source reference
        format - Format string, according to String.format(String, Object...).
        args - Format string arguments, according to String.format(String, Object...)
        Returns:
        Object if it is not null
        Throws:
        SourceException - if object is null