Class SourceException

All Implemented Interfaces:
Serializable
Direct Known Subclasses:
InvalidSubstatementException, MissingSubstatementException, YangVersionLinkageException

public class SourceException extends StatementSourceException
Thrown to indicate error in YANG model source.
See Also:
  • Constructor Details

    • SourceException

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

      public SourceException(@NonNull String message, @NonNull StatementSourceReference sourceRef, 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
      sourceRef - Statement source
      cause - Underlying cause of this exception
    • SourceException

      public SourceException(@NonNull StatementSourceReference source, @NonNull String format, Object... args)
      Create a new instance with the specified source and a formatted message. The message will be appended with the source reference.
      Parameters:
      source - Statement source
      format - Format string, according to String.format(String, Object...).
      args - Format string arguments, according to String.format(String, Object...)
    • SourceException

      public SourceException(@NonNull StatementSourceReference source, Throwable cause, @NonNull String format, Object... args)
      Create a new instance with the specified source and a formatted message. The message will be appended with the source reference.
      Parameters:
      source - Statement source
      cause - Underlying cause of this exception
      format - Format string, according to String.format(String, Object...).
      args - Format string arguments, according to String.format(String, Object...)
    • SourceException

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

      public SourceException(@NonNull String message, @NonNull CommonStmtCtx stmt, 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
      stmt - Statement context, not retained
      cause - Underlying cause of this exception
    • SourceException

      public SourceException(@NonNull CommonStmtCtx stmt, @NonNull String format, Object... args)
      Create a new instance with the specified source and a formatted message. The message will be appended with the source reference.
      Parameters:
      stmt - Statement context, not retained
      format - Format string, according to String.format(String, Object...).
      args - Format string arguments, according to String.format(String, Object...)
    • SourceException

      public SourceException(@NonNull CommonStmtCtx stmt, Throwable cause, @NonNull String format, Object... args)
      Create a new instance with the specified source and a formatted message. The message will be appended with the source reference.
      Parameters:
      stmt - Statement context, not retained
      cause - Underlying cause of this exception
      format - Format string, according to String.format(String, Object...).
      args - Format string arguments, according to String.format(String, Object...)
  • Method Details

    • throwIf

      public static void throwIf(boolean expression, @NonNull CommonStmtCtx stmt, @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
      stmt - Statement context, not retained
      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.
    • 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
    • throwIfNull

      public static <T> @NonNull T throwIfNull(@Nullable T obj, @NonNull CommonStmtCtx stmt, @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
      stmt - Statement context, not retained
      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
    • unwrap

      public static <T> @NonNull 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. If it is present, this method will return the unwrapped value.
      Parameters:
      opt - Optional 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 unwrapped from the opt optional
      Throws:
      SourceException - if the optional is not present
    • unwrap

      public static <T> @NonNull T unwrap(Optional<T> opt, @NonNull CommonStmtCtx stmt, @NonNull String format, Object... args)
      Throw an instance of this exception if an optional is not present. If it is present, this method will return the unwrapped value.
      Parameters:
      opt - Optional to be checked
      stmt - Statement context, not retained
      format - Format string, according to String.format(String, Object...).
      args - Format string arguments, according to String.format(String, Object...)
      Returns:
      Object unwrapped from the opt optional
      Throws:
      SourceException - if the optional is not present