Class Throw

java.lang.Object
io.sundr.model.Throw
All Implemented Interfaces:
Node, Renderable, Statement, WithReferences

public class Throw extends Object implements Statement
  • Constructor Details

  • Method Details

    • getException

      public Expression getException()
    • getReferences

      public Set<ClassRef> getReferences()
      Specified by:
      getReferences in interface WithReferences
    • render

      public String render()
      Description copied from interface: Renderable
      Render the type into a String for the purpose of code generation. This is slightly different from the `toString()` method as `toString()` is mostly needed for logging / debugging and should be idempotent. Regarding idempotency this method may yield different result based on the context it is used even if the internal state of the object does not change. An example of such case, is a reference to class that may change based on the package from which it's refenced.
      Specified by:
      render in interface Renderable
      Returns:
      the String representation of the object as it's meant to appear in the generated code.
    • newInstance

      public static Throw newInstance(Class<?> exceptionClass, String message)
      Creates a throw statement for a new instance of the specified exception class with a message.
      Parameters:
      exceptionClass - The exception class
      message - The exception message
      Returns:
      A new Throw statement
    • newInstance

      public static Throw newInstance(ClassRef exceptionClassRef, String message)
      Creates a throw statement for a new instance of the specified exception class with a message.
      Parameters:
      exceptionClassRef - The exception class reference
      message - The exception message
      Returns:
      A new Throw statement
    • newInstance

      public static Throw newInstance(Class<?> exceptionClass, Expression messageExpression)
      Creates a throw statement for a new instance of the specified exception class with an expression message.
      Parameters:
      exceptionClass - The exception class
      messageExpression - The exception message expression
      Returns:
      A new Throw statement
    • newInstance

      public static Throw newInstance(ClassRef exceptionClassRef, Expression messageExpression)
      Creates a throw statement for a new instance of the specified exception class with an expression message.
      Parameters:
      exceptionClassRef - The exception class reference
      messageExpression - The exception message expression
      Returns:
      A new Throw statement
    • runtimeException

      public static Throw runtimeException(String message)
      Creates a throw statement for RuntimeException with a simple message.
      Parameters:
      message - The exception message
      Returns:
      A new Throw statement
    • runtimeException

      public static Throw runtimeException(Expression messageExpression)
      Creates a throw statement for RuntimeException with an expression message.
      Parameters:
      messageExpression - The exception message expression
      Returns:
      A new Throw statement
    • illegalArgument

      public static Throw illegalArgument(String message)
      Creates a throw statement for IllegalArgumentException with a simple message.
      Parameters:
      message - The exception message
      Returns:
      A new Throw statement
    • illegalArgument

      public static Throw illegalArgument(Expression messageExpression)
      Creates a throw statement for IllegalArgumentException with an expression message.
      Parameters:
      messageExpression - The exception message expression
      Returns:
      A new Throw statement
    • illegalState

      public static Throw illegalState(String message)
      Creates a throw statement for IllegalStateException with a simple message.
      Parameters:
      message - The exception message
      Returns:
      A new Throw statement
    • illegalState

      public static Throw illegalState(Expression messageExpression)
      Creates a throw statement for IllegalStateException with an expression message.
      Parameters:
      messageExpression - The exception message expression
      Returns:
      A new Throw statement