Class StringBuilderGen

java.lang.Object
io.quarkus.gizmo2.creator.ops.ObjectOps
org.jboss.jandex.gizmo2.StringBuilderGen
All Implemented Interfaces:
io.quarkus.gizmo2.creator.ops.ComparableOps

public final class StringBuilderGen extends io.quarkus.gizmo2.creator.ops.ObjectOps implements io.quarkus.gizmo2.creator.ops.ComparableOps
Generator of StringBuilder call chains. The expected usage pattern is:
  1. Create an instance using ofNew(BlockCreator)
  2. Append to it using append(Expr)
  3. Create the final string using ObjectOps.toString_()
If you need to perform other operations on the StringBuilder that this class doesn't provide, you should create an instance using of(Var, BlockCreator), which allows passing an already created StringBuilder. This class itself doesn't provide access to the underlying object.
  • Field Summary

    Fields inherited from class io.quarkus.gizmo2.creator.ops.ObjectOps

    bc, obj
  • Method Summary

    Modifier and Type
    Method
    Description
    append(char constant)
    Appends the given char constant to this StringBuilder.
    append(io.quarkus.gizmo2.Expr expr)
    Appends the string value of given expr to this StringBuilder.
    append(String constant)
    Appends the given String constant to this StringBuilder.
    appendCodePoint(int codePoint)
    Appends the given code point to this StringBuilder.
    appendCodePoint(io.quarkus.gizmo2.Expr codePoint)
    Appends the given code point to this StringBuilder.
    io.quarkus.gizmo2.Expr
    compareTo(io.quarkus.gizmo2.Expr other)
     
    of(io.quarkus.gizmo2.Var stringBuilder, io.quarkus.gizmo2.creator.BlockCreator bc)
    Creates a StringBuilder generator that helps to generate a chain of append calls and a final toString call.
    ofNew(int capacity, io.quarkus.gizmo2.creator.BlockCreator bc)
    Allocates a local variable in the given block as if by new StringBuilder(capacity) and passes it to of(Var, BlockCreator).
    ofNew(io.quarkus.gizmo2.creator.BlockCreator bc)
    Allocates a local variable in the given block as if by new StringBuilder() and passes it to of(Var, BlockCreator).
    void
    setLength(int length)
    Set the length of this StringBuilder.
    void
    setLength(io.quarkus.gizmo2.Expr length)
    Set the length of this StringBuilder.

    Methods inherited from class io.quarkus.gizmo2.creator.ops.ObjectOps

    blockCreator, equals_, getClass_, hashCode_, invokeInstance, invokeInstance, invokeInstance, invokeInstance, invokeInstance, receiver, receiverType, toString_

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • ofNew

      public static StringBuilderGen ofNew(io.quarkus.gizmo2.creator.BlockCreator bc)
      Allocates a local variable in the given block as if by new StringBuilder() and passes it to of(Var, BlockCreator).
      Parameters:
      bc - the block in which the new StringBuilder should be created
      Returns:
      the result of of(Var, BlockCreator) called on the new StringBuilder
    • ofNew

      public static StringBuilderGen ofNew(int capacity, io.quarkus.gizmo2.creator.BlockCreator bc)
      Allocates a local variable in the given block as if by new StringBuilder(capacity) and passes it to of(Var, BlockCreator).
      Parameters:
      bc - the block in which the new StringBuilder should be created
      Returns:
      the result of of(Var, BlockCreator) called on the new StringBuilder
    • of

      public static StringBuilderGen of(io.quarkus.gizmo2.Var stringBuilder, io.quarkus.gizmo2.creator.BlockCreator bc)
      Creates a StringBuilder generator that helps to generate a chain of append calls and a final toString call.
       StringBuilderGen str = StringBuilderGen.of(theStringBuilder, bc);
       str.append("constant");
       str.append(someExpr);
       Expr result = str.toString_();
       
      The append method mimics the regular StringBuilder.append, so it accepts Exprs of all types for which StringBuilder has an overload:
      • primitive types
      • char[]
      • java.lang.String
      • java.lang.CharSequence
      • java.lang.Object
      Notably, arrays except of char[] are appended using Object.toString and if Arrays.toString should be used, it must be generated manually (see BlockCreator.arrayToString(Expr)).

      Methods for appending only a part of char[] or CharSequence are not provided.

      Note that the returned instance may be reused to append to the same StringBuilder in the same BlockCreator multiple times. This allows using StringBuilderGen in the same manner a StringBuilder would normally be used.

      Parameters:
      stringBuilder - the StringBuilder
      bc - the BlockCreator
      Returns:
      a convenience wrapper for accessing instance methods of the given StringBuilder
    • append

      public StringBuilderGen append(io.quarkus.gizmo2.Expr expr)
      Appends the string value of given expr to this StringBuilder.
      Parameters:
      expr - the value to append
      Returns:
      this instance
    • append

      public StringBuilderGen append(char constant)
      Appends the given char constant to this StringBuilder.
      Parameters:
      constant - the value to append
      Returns:
      this instance
    • append

      public StringBuilderGen append(String constant)
      Appends the given String constant to this StringBuilder.
      Parameters:
      constant - the value to append
      Returns:
      this instance
    • appendCodePoint

      public StringBuilderGen appendCodePoint(io.quarkus.gizmo2.Expr codePoint)
      Appends the given code point to this StringBuilder.
      Parameters:
      codePoint - the value to append (must not be null)
      Returns:
      this instance
    • appendCodePoint

      public StringBuilderGen appendCodePoint(int codePoint)
      Appends the given code point to this StringBuilder.
      Parameters:
      codePoint - the value to append
      Returns:
      this instance
    • setLength

      public void setLength(io.quarkus.gizmo2.Expr length)
      Set the length of this StringBuilder.
      Parameters:
      length - the length expression (must not be null)
    • setLength

      public void setLength(int length)
      Set the length of this StringBuilder.
      Parameters:
      length - the constant length
    • compareTo

      public io.quarkus.gizmo2.Expr compareTo(io.quarkus.gizmo2.Expr other)
      Specified by:
      compareTo in interface io.quarkus.gizmo2.creator.ops.ComparableOps