Package org.jboss.jandex.gizmo2
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:
- Create an instance using
ofNew(BlockCreator) - Append to it using
append(Expr) - Create the final string using
ObjectOps.toString_()
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 TypeMethodDescriptionappend(char constant) Appends the givencharconstant to thisStringBuilder.append(io.quarkus.gizmo2.Expr expr) Appends the string value of givenexprto thisStringBuilder.Appends the givenStringconstant to thisStringBuilder.appendCodePoint(int codePoint) Appends the given code point to thisStringBuilder.appendCodePoint(io.quarkus.gizmo2.Expr codePoint) Appends the given code point to thisStringBuilder.io.quarkus.gizmo2.ExprcompareTo(io.quarkus.gizmo2.Expr other) static StringBuilderGenof(io.quarkus.gizmo2.Var stringBuilder, io.quarkus.gizmo2.creator.BlockCreator bc) Creates aStringBuildergenerator that helps to generate a chain ofappendcalls and a finaltoStringcall.static StringBuilderGenofNew(int capacity, io.quarkus.gizmo2.creator.BlockCreator bc) Allocates a local variable in the given block as if bynew StringBuilder(capacity)and passes it toof(Var, BlockCreator).static StringBuilderGenofNew(io.quarkus.gizmo2.creator.BlockCreator bc) Allocates a local variable in the given block as if bynew StringBuilder()and passes it toof(Var, BlockCreator).voidsetLength(int length) Set the length of thisStringBuilder.voidsetLength(io.quarkus.gizmo2.Expr length) Set the length of thisStringBuilder.Methods inherited from class io.quarkus.gizmo2.creator.ops.ObjectOps
blockCreator, equals_, getClass_, hashCode_, invokeInstance, invokeInstance, invokeInstance, invokeInstance, invokeInstance, receiver, receiverType, toString_
-
Method Details
-
ofNew
Allocates a local variable in the given block as if bynew StringBuilder()and passes it toof(Var, BlockCreator).- Parameters:
bc- the block in which the newStringBuildershould be created- Returns:
- the result of
of(Var, BlockCreator)called on the newStringBuilder
-
ofNew
Allocates a local variable in the given block as if bynew StringBuilder(capacity)and passes it toof(Var, BlockCreator).- Parameters:
bc- the block in which the newStringBuildershould be created- Returns:
- the result of
of(Var, BlockCreator)called on the newStringBuilder
-
of
public static StringBuilderGen of(io.quarkus.gizmo2.Var stringBuilder, io.quarkus.gizmo2.creator.BlockCreator bc) Creates aStringBuildergenerator that helps to generate a chain ofappendcalls and a finaltoStringcall.StringBuilderGen str = StringBuilderGen.of(theStringBuilder, bc); str.append("constant"); str.append(someExpr); Expr result = str.toString_();Theappendmethod mimics the regularStringBuilder.append, so it acceptsExprs of all types for whichStringBuilderhas an overload:- primitive types
char[]java.lang.Stringjava.lang.CharSequencejava.lang.Object
char[]are appended usingObject.toStringand ifArrays.toStringshould be used, it must be generated manually (seeBlockCreator.arrayToString(Expr)).Methods for appending only a part of
char[]orCharSequenceare not provided.Note that the returned instance may be reused to append to the same
StringBuilderin the sameBlockCreatormultiple times. This allows usingStringBuilderGenin the same manner aStringBuilderwould normally be used.- Parameters:
stringBuilder- theStringBuilderbc- theBlockCreator- Returns:
- a convenience wrapper for accessing instance methods of the given
StringBuilder
-
append
Appends the string value of givenexprto thisStringBuilder.- Parameters:
expr- the value to append- Returns:
- this instance
-
append
Appends the givencharconstant to thisStringBuilder.- Parameters:
constant- the value to append- Returns:
- this instance
-
append
Appends the givenStringconstant to thisStringBuilder.- Parameters:
constant- the value to append- Returns:
- this instance
-
appendCodePoint
Appends the given code point to thisStringBuilder.- Parameters:
codePoint- the value to append (must not benull)- Returns:
- this instance
-
appendCodePoint
Appends the given code point to thisStringBuilder.- Parameters:
codePoint- the value to append- Returns:
- this instance
-
setLength
public void setLength(io.quarkus.gizmo2.Expr length) Set the length of thisStringBuilder.- Parameters:
length- the length expression (must not benull)
-
setLength
public void setLength(int length) Set the length of thisStringBuilder.- Parameters:
length- the constant length
-
compareTo
public io.quarkus.gizmo2.Expr compareTo(io.quarkus.gizmo2.Expr other) - Specified by:
compareToin interfaceio.quarkus.gizmo2.creator.ops.ComparableOps
-