CodeLines

public final class CodeLines

The aggregator of the JavaScript output.

This class serves as the JS code storage as well as provides the convenience methods for adding the code.

The writable representation of the output may be obtained through the toString method.

Constructors

Link copied to clipboard
public void CodeLines()
Creates an instance of the JsOutput with the default indentation.
public void CodeLines(Indent indentation)
Creates an instance of the JsOutput with the custom indentation.

Functions

Link copied to clipboard
public void append(Snippet snippet)
Appends the lines of the snippet.
public void append(CodeLine line)
Appends the code line and indents it to the current indent level.
public void append(CodeLines appended)
Appends another code lines to this code.
public void append(String codeLine)
Appends the line of code on the current indent level.
Link copied to clipboard
public static CodeLines commaSeparated(List<CodeLine> lines)
Merges lines by addition of a comma to each line except the last one.
Link copied to clipboard
public void decreaseDepth()
Manually decreases the current indent level.
Link copied to clipboard
public void enterBlock(String blockHeader)
Enters block with the custom header.
Link copied to clipboard
public void enterElseBlock()
Closes the current if block and enters the else block.
Link copied to clipboard
public void enterIfBlock(String condition)
Enters the if block body.
Link copied to clipboard
public void enterMethod(String methodName, Array<String> methodArgs)
Declares JS method and enters its body.
Link copied to clipboard
public boolean equals(Object o)
Link copied to clipboard
public void exitBlock()
Exits the if, else or custom block.
Link copied to clipboard
public void exitMethod()
Exits method declaration.
Link copied to clipboard
public int hashCode()
Link copied to clipboard
public void ifNotNull(String value)
Enters the if block checking that the given value is not null.
Link copied to clipboard
public void ifNotNullOrUndefined(String value)
Enters the if block checking that given value is not null or undefined.
Link copied to clipboard
public void ifNotUndefined(String value)
Enters the if block checking that the given value is not undefined.
Link copied to clipboard
public void ifNull(String value)
Enters the if block checking that the given value is null.
Link copied to clipboard
public void increaseDepth()
Manually increases the current indent level.
Link copied to clipboard
public String toString()
Concatenates all the code lines with the correct indentation and line separator.