sugar4j
Class Sugar4j<T extends Sugar4j<?>>

java.lang.Object
  extended by sugar4j.Sugar4j<T>
All Implemented Interfaces:
Creator, JavaLang, JavaUtil
Direct Known Subclasses:
ExprBase, InstanceBuilder, Schema2Package

public abstract class Sugar4j<T extends Sugar4j<?>>
extends Object
implements Creator, JavaLang, JavaUtil

Abstract base class for all sugar generating needs.
The only method to implement is Creator#doCreate(), which creates the content of the sugar.

The template argument T is generally the same as the name of the Sugar4j subclass. Something like:

 public class MySugar extends Sugar4j<MySugar> {
 }
 

It is suggested that users of Sugar4j introduce a subclass and further derive from that subclass instead of deriving from Sugar4j directly. Something like:

 abstract public class MyCompanySugar extends Sugar4j<MyCompanySugar> {
   public MyCompanySugar() {
   }
   public MyCompanySugar(Object classs) {
     super(classs);
   }
 }
 
 public class MyModelSugar extends MyCompanySugar {
   public void doCreate() {
      ... 
   }
 }
 

The generated java code is not formatted in any way. If needed, it is up to the programmer to format the result in a subsequent step. Formatting also includes new lines so most java code will be written on one line. This makes it hard to read for, in example, a debugging session. You may set the pretty print setPrettyPrint(boolean) flag so that the resulting code gets new lines/indent spaces. Javadoc is always set on new lines.

Version:
$Id: Sugar4j.java,v 1.63 2008/02/12 00:44:52 krizzdewizz Exp $
Author:
krizzdewizz
See Also:
Creator.doCreate()

Constructor Summary
Sugar4j()
          Default constructor.
Sugar4j(Object classs)
          Constructs with given class name.
Sugar4j(Object packagee, Object classSimpleName)
          Constructs with given package and simple class name.
 
Method Summary
 T _add(Object s)
          Adds raw content to the output.
 Date _addDefaultFileHeader()
          Adds the default file header.
 T abstractt()
          Yields abstract.
 T add(Object left, Object right)
          Math add or string concatenation +.
 T and(Object left, Object right)
          Conditional and &&.
 T annotate(Object annotation, Object... values)
          Annotates a java element
 T annotation()
          Creates an annotation type using this getClassSimpleName() as the name.
 T annotation(String name)
          Creates an annotation type.
static String arrayAt(Object array, Object index)
          Access an array element at a given index.
static String arrayInit(Object... initializers)
          Returns an array initializer for the given elements.
static String arrayLength(Object array)
          Access the length member of the given array.
static String arrayNew(Object classss, Object... sizes)
          Creates a new array with the given sizes.
static String arrayNeww(Object classss, Object... initializers)
          Creates a new array and initializes it with the given initializers.
static String arrayOf(Object classss)
          An array of the given classss.
 T assertt(Object expr, Object... message)
          Yields an assert statement.
 T assign(Object... leftOrLeftAndRight)
          Yields a =.
 T assignBitAnd(Object left, Object right)
          Yields a &= expression.
 T assignBitOr(Object left, Object right)
          Yields a |= expression.
 T assignBitXor(Object left, Object right)
          Yields a ^= expression.
 T assignDivide(Object left, Object right)
          Yields a /= expression.
 T assignLeftShift(Object left, Object right)
          Yields a <<= expression.
 T assignMinus(Object left, Object right)
          Yields a -= expression.
 T assignPlus(Object left, Object right)
          Yields a += expression.
 T assignRemainder(Object left, Object right)
          Yields a %= expression.
 T assignRightShiftSigned(Object left, Object right)
          Yields a >>= expression.
 T assignRightShiftUnsigned(Object left, Object right)
          Yields a >>>= expression.
 T assignTimes(Object left, Object right)
          Yields a *= expression.
 T attribute(Object classss, String name, Object... defaultt)
          Adds an annotation attribute inside an annotation type declaration.
 T begin()
          Begins a block.
 T beginCompilationUnit()
          Begins this compilation unit.
 T bitAnd(Object left, Object right)
          Bitwise and &.
 T bitOr(Object left, Object right)
          Bitwise or |.
 T bitXor(Object left, Object right)
          Bitwise xor ^.
 T breakk()
          Yields a break; statement, including the eos() call.
 T call(Object object, String method, Object... params)
          Calls a method on a given object.
 T calll(String method, Object... params)
          Calls a method on this.
 T casee(Object expr)
          Yields a case statement, including the colon (:).
 T cast(Object classss, Object... expr)
          Yields a cast.
 T catchAndRethrowAs(Object catchedExceptionClass, Object asExceptionClass)
          Adds a catch block which catches all exceptions of type catchedExceptionClass and re-throws (wrap) the exception in a new asExceptionClass.
 T catchh(Object exClass, String exName)
          Adds a catch handler.
 T classs()
          Adds a class using this getClassSimpleName().
 T classs(String name)
          Adds a class using the given name used primarly for inner classes.
 T complement(Object expr)
           
 T concat(Object... exprs)
           
 T constructor(Object... params)
           
 T constructorr(String name, Object... params)
           
 T continuee()
           
 T create()
           
 T decr(Object expr)
           
 T decrPre(Object expr)
           
 T defaultt()
           
 T div(Object left, Object right)
           
 T doc(String text)
          Adds a comment line.
 T docAuthor(String author, String... comment)
          Adds an @autor tag.
 T docBegin()
          Begins comment mode.
 T docEnd()
          Ends comment mode and adds add("/").nl()
 T docParam(String name, String comment)
           
 T docReturn(String comment)
           
 T docSee(Object classss, String method, Object... paramTypes)
           
 T docSingleLine(String comment)
           
 T docThrows(Object exception, String comment)
           
 T doo()
           
 T dot()
           
 T elsee()
           
 T elseif(Object expr)
           
 T empty()
           
 T end()
           
 T enumItem(String name, Object... params)
           
 T enumm()
           
 T enumm(String name)
           
 T enummm(Object... items)
           
 T enummmm(String name, Object... items)
           
 T eos()
           
 T eq(Object left, Object right)
           
 ExprBase<? extends ExprBase<?>> expr()
           
static String expr(Object obj)
          Encloses the given obj within parens ( () ).
 T extendss(Object name)
           
 T finall()
           
 T finallyy()
           
 T forr(Object init, Object condition, Object updater)
           
 T forrr(Object indexFrom, Object indexTo)
           
 T forrr(Object itemClass, String itemName, Object iterable)
           
 T ge(Object left, Object right)
           
static String get(Object... names)
          Access a member.
 boolean getAutoImport()
          Returns whether to automatically import where required.
 Object getClasss()
          Returns the full qualified name of the class that this class creates.
 String getClassSimpleName()
           
static String getClassSimpleName(Object classss)
          Returns the simple, local name of the given full qualified class name.
 String getPackage()
           
static String getPackage(Object classss)
          Returns the package name of the given full qualified class name.
 boolean getPrettyPrint()
          Returns whether to include new lines / indent spaces to make the resulting code human readable.
 T gt(Object left, Object right)
           
 T iff(Object expr)
           
 T ifff(Object test, Object trueExpr, Object falseExpr)
           
 T implementss(Object... itfs)
           
 void importAll(Object packagee)
           
 String importStatic(Object name)
           
 String importt(Object name)
           
 T incr(Object expr)
           
 T incrPre(Object expr)
           
 T instanceoff(Object left, Object right)
           
 T interfacee()
           
 T interfacee(String name)
           
 T le(Object left, Object right)
           
 T leftShift(Object left, Object right)
           
 T lt(Object left, Object right)
           
 T mainn(String... argsName)
           
 T method(Object returnType, String name, Object... params)
           
 T minus(Object expr)
           
 T minus(Object left, Object right)
           
 T ne(Object left, Object right)
           
 T neww(Object classss, Object... params)
           
 T next()
           
 T nl()
           
 T not(Object expr)
           
 T or(Object left, Object right)
           
 T Override()
          Adds a Override annotation.
 T packagee(String name)
           
 T plus(Object expr)
           
 T plus(Object left, Object right)
           
 T privatee()
           
static String propertyGet(Object propertyName)
           
static String propertySet(Object propertyName)
           
 T protectedd()
           
 T publicc()
           
 T question()
          Adds a question mark (?
static String quote(char c)
          Quotes/escapes the given char.
static String quote(Object s)
          Quotes/escapes the given string.
 T remainder(Object left, Object right)
           
 T returnn()
           
 T returnn(Object value)
           
 T rightShiftSigned(Object left, Object right)
           
 T rightShiftUnsigned(Object left, Object right)
           
 void setAutoImport(boolean autoImport)
          Sets whether to automatically import where required.
 void setClasss(Object classs)
          Sets the full qualified name of the class that this class creates.
 void setPrettyPrint(boolean prettyPrint)
          Sets whether to include new lines / indent spaces to make the resulting code human readable.
 T staticc()
          Adds static.
 T superr(String method, Object... params)
          Calls the given method on super.
 T superrr(Object classss)
          Super of the given class used for wildcard type arguments.
 T SuppressWarnings(Object firstValue, Object... moreValues)
          Adds a SuppressWarnings annotation.
 T switchh(Object expr)
          Adds a switch.
 T synchronizedd(Object expr)
          Adds a synchronized.
 T throwss(Object... exceptions)
          Adds a throws declaration at the end of a ctor/method declaration.
 T throww()
          Adds a throw statement.
 T times(Object left, Object right)
          Adds a * operation
 File toJavaFile(File srcFolder)
          Returns the source file for this classs.
 String toString()
          Returns the content added so far (tags may not be replaced yet).
 T tryy()
           
static String typeArg(Object classss, Object firstTypeArg, Object... moreTypeArgs)
          Adds generic type parameters to the given classss.
static String typeArgExtendss(Object typeArg, Object extendsClass, Object... extendsInterfaces)
          Adds generic wildcard type parameter.
 T typeArgg(Object... args)
          Used to add type arguments in front of a method declaration.
static String typeArgMethod(Object... typeArgsAndMethodName)
          Returns a parametrized method name used for later invocation with call().
 T var(Object classss, Object nameOrExpr, Object... init)
          Adds a variable declaration (local variable, member variable, parameter...).
static String varargs(Object classss)
          Used to declare a 'varargs' method argument.
 T whilee(Object expr)
          Adds a while.
 

Constructor Detail

Sugar4j

public Sugar4j()
Default constructor.

Note that methods like classs(), enumm() and interfacee() throw Sugar4jException if the classs member is not intialized.

See Also:
setClasss(Object)

Sugar4j

public Sugar4j(Object classs)
Constructs with given class name.

Parameters:
classs - The full qualified name of the class that this class creates.

Sugar4j

public Sugar4j(Object packagee,
               Object classSimpleName)
Constructs with given package and simple class name.

Parameters:
packagee - The package name
classSimpleName - The simple (local) name of the class that this class creates.
Method Detail

propertyGet

public static String propertyGet(Object propertyName)

propertySet

public static String propertySet(Object propertyName)

toJavaFile

public File toJavaFile(File srcFolder)
Returns the source file for this classs.

Parameters:
srcFolder - The base source folder, parent/ancestor folder for the given class.
Returns:
Source file (.java)

arrayAt

public static String arrayAt(Object array,
                             Object index)
Access an array element at a given index.

arrayIndex("arr", 0) --> arr[0]

Parameters:
array -
index -
Returns:
String

arrayInit

public static String arrayInit(Object... initializers)
Returns an array initializer for the given elements.

arrayInit(0, 1, 2) --> {0, 1, 2}

Parameters:
initializers - May be empty in which case the empty initializer ({}) is returned
Returns:
String

arrayLength

public static String arrayLength(Object array)
Access the length member of the given array.

Equivalent of:
get(array, length)

Parameters:
array -
Returns:
String
See Also:
JavaLang.length

arrayNew

public static String arrayNew(Object classss,
                              Object... sizes)
Creates a new array with the given sizes.

arrayNew(String, 2) --> new String[2]

Parameters:
classss - Classname of the array
sizes - Size of the array. If length == 0, the array's size is not specified ([]).
Returns:
String

arrayNeww

public static String arrayNeww(Object classss,
                               Object... initializers)
Creates a new array and initializes it with the given initializers.

arrayNeww(Integer, 1, 2, 3) --> new Integer[] {1, 2, 3}

Parameters:
classss -
initializers -
Returns:
String

arrayOf

public static String arrayOf(Object classss)
An array of the given classss.

arrayOf(String) --> String[]

Parameters:
classss -
Returns:
String

expr

public static String expr(Object obj)
Encloses the given obj within parens ( () ).

expr("hello") --> (hello)

Parameters:
obj -
Returns:
String

get

public static String get(Object... names)
Access a member.
Concatenates all names with a dot (.) in between.

get(String, classs) --> String.class

get("a", "b", "c") --> a.b.c

Parameters:
names - Array of names
Returns:
String

getClassSimpleName

public static String getClassSimpleName(Object classss)
Returns the simple, local name of the given full qualified class name.

getClassSimpleName("java.lang.String") --> String

Parameters:
classss - Full qualified name or local name of the class
Returns:
String

getPackage

public static String getPackage(Object classss)
Returns the package name of the given full qualified class name.

getPackageName("java.lang.String") --> java.lang

Parameters:
classss - Full qualified name or local name (no package) of the class
Returns:
String. The empty string if the class does not have a package

varargs

public static String varargs(Object classss)
Used to declare a 'varargs' method argument. This method is mainly used together with the method() method.

 method(voidd, "myMethod", varargss("String"), "names").begin();
 {
 }
 end();
 

Parameters:
classss -
Returns:
String
See Also:
method(Object, String, Object...)

quote

public static String quote(char c)
Quotes/escapes the given char.

Parameters:
c -
Returns:
String

quote

public static String quote(Object s)
Quotes/escapes the given string.

Parameters:
s -
Returns:
String

typeArgMethod

public static String typeArgMethod(Object... typeArgsAndMethodName)
Returns a parametrized method name used for later invocation with call().

Example:

 call("Collections", typeArgMethod(String, "emptyList") -> Collections.<String>emptyList()
 

Parameters:
typeArgsAndMethodName -
Returns:
String

typeArg

public static String typeArg(Object classss,
                             Object firstTypeArg,
                             Object... moreTypeArgs)
Adds generic type parameters to the given classss.

typeArg("List", String) --> List<String>
typeArg("Map", String, Integer) --> Map<String, Integer>

Parameters:
classss - Class to enrich with type parameters
firstTypeArg - First type argument
moreTypeArgs - More type argument
Returns:
String

typeArgExtendss

public static String typeArgExtendss(Object typeArg,
                                     Object extendsClass,
                                     Object... extendsInterfaces)
Adds generic wildcard type parameter.

 classs(typeArg("MyClass", typeArgExtendss("T", "Runnable"))).begin();
 {
 }
 end();   
 
yields
 class MyClass<T extends Runnable> {
 }
 

Parameters:
typeArg - Name of the type parameter (in example T)
extendsClass - Name of the class that typeArg extends
extendsInterfaces - More interfaces that typeArg extends/implements
Returns:
String

_add

public T _add(Object s)
Adds raw content to the output.

Note that this method is not necessarily required to create valid java code. Usage of this method should be avoided.

Parameters:
s - Content to add.
Returns:
this

abstractt

public T abstractt()
Yields abstract.

Returns:
this

add

public T add(Object left,
             Object right)
Math add or string concatenation +.

Parameters:
left -
right -
Returns:
this

and

public T and(Object left,
             Object right)
Conditional and &&.

Parameters:
left -
right -
Returns:
this

annotate

public T annotate(Object annotation,
                  Object... values)
Annotates a java element

Parameters:
annotation - Name of the annotation without the leading @ character.
values - If length == 0, no values are added (marker annotation like @Override). If length == 1, its the default value value. If length > 1, pairs of [name]=[value].
Returns:
this
Throws:
Sugar4jException - if values.length > 1 and values are not pairs

annotation

public T annotation()
Creates an annotation type using this getClassSimpleName() as the name.

Returns:
this
See Also:
annotation(String), getClassSimpleName()

annotation

public T annotation(String name)
Creates an annotation type.

Parameters:
name - Name of the annotation without the leading @ character
Returns:
this

assertt

public T assertt(Object expr,
                 Object... message)
Yields an assert statement.

Parameters:
expr - boolean expression
message - Optional. If length > 0, the first element designates the message for the assert statement.
Returns:
this

assign

public T assign(Object... leftOrLeftAndRight)
Yields a =.
Used to further assign an expression to, in example, a variable declaration. Instead of writing:
 var(String, "s", expr().calll("toString").eos()); 
 
One could write:
 var(String, "s").assign().calll("toString").eos();
 

Parameters:
leftOrLeftAndRight - if length == 0 only the = is yield. If length == 1, its the left side of the assignment. If length == 2 the second index is the right side of the assignment.
Returns:
this

assignBitAnd

public T assignBitAnd(Object left,
                      Object right)
Yields a &= expression.

Parameters:
left -
right -
Returns:
this

assignBitOr

public T assignBitOr(Object left,
                     Object right)
Yields a |= expression.

Parameters:
left -
right -
Returns:
this

assignBitXor

public T assignBitXor(Object left,
                      Object right)
Yields a ^= expression.

Parameters:
left -
right -
Returns:
this

assignDivide

public T assignDivide(Object left,
                      Object right)
Yields a /= expression.

Parameters:
left -
right -
Returns:
this

assignLeftShift

public T assignLeftShift(Object left,
                         Object right)
Yields a <<= expression.

Parameters:
left -
right -
Returns:
this

assignMinus

public T assignMinus(Object left,
                     Object right)
Yields a -= expression.

Parameters:
left -
right -
Returns:
this

assignPlus

public T assignPlus(Object left,
                    Object right)
Yields a += expression.

Parameters:
left -
right -
Returns:
this

assignRemainder

public T assignRemainder(Object left,
                         Object right)
Yields a %= expression.

Parameters:
left -
right -
Returns:
this

assignRightShiftSigned

public T assignRightShiftSigned(Object left,
                                Object right)
Yields a >>= expression.

Parameters:
left -
right -
Returns:
this

assignRightShiftUnsigned

public T assignRightShiftUnsigned(Object left,
                                  Object right)
Yields a >>>= expression.

Parameters:
left -
right -
Returns:
this

assignTimes

public T assignTimes(Object left,
                     Object right)
Yields a *= expression.

Parameters:
left -
right -
Returns:
this

attribute

public T attribute(Object classss,
                   String name,
                   Object... defaultt)
Adds an annotation attribute inside an annotation type declaration.

Parameters:
classss - Class of the attribute
name - Name of the attribute
defaultt - Optional. If length > 0, the first element designates the default value for the annotation attribute
Returns:
this

begin

public T begin()
Begins a block.

Returns:
this

beginCompilationUnit

public T beginCompilationUnit()
Begins this compilation unit.
This is generally the first call in the implemented doCreate() method.
Writes this package name and inserts the ImportMananger's import list tag.

Returns:
this
See Also:
Creator.doCreate()

bitAnd

public T bitAnd(Object left,
                Object right)
Bitwise and &.

Parameters:
left -
right -
Returns:
this

bitOr

public T bitOr(Object left,
               Object right)
Bitwise or |.

Parameters:
left -
right -
Returns:
this

bitXor

public T bitXor(Object left,
                Object right)
Bitwise xor ^.

Parameters:
left -
right -
Returns:
this

breakk

public T breakk()
Yields a break; statement, including the eos() call.

Returns:
this

call

public T call(Object object,
              String method,
              Object... params)
Calls a method on a given object.

Parameters:
object - Object to call. If null, the method is called on this.
method - Name of the method
params - Arguments for the method
Returns:
this

calll

public T calll(String method,
               Object... params)
Calls a method on this.

Parameters:
method -
params -
Returns:
this
See Also:
call(Object, String, Object...)

casee

public T casee(Object expr)
Yields a case statement, including the colon (:).

Parameters:
expr -
Returns:
this

cast

public T cast(Object classss,
              Object... expr)
Yields a cast.

Parameters:
classss -
expr - Optional. If length == 0 the classss is enclosed within parens ( ()). If length > 0, the expression is casted using Class#cast()
Returns:
this
See Also:
Class.cast(Object)

catchAndRethrowAs

public T catchAndRethrowAs(Object catchedExceptionClass,
                           Object asExceptionClass)
Adds a catch block which catches all exceptions of type catchedExceptionClass and re-throws (wrap) the exception in a new asExceptionClass.

Example:

 try {
 
   ...
   
 } catch ([catchedExceptionClass] e) {
   throw new [asExceptionClass](e);
 }
 

Parameters:
catchedExceptionClass -
asExceptionClass -
Returns:
this

catchh

public T catchh(Object exClass,
                String exName)
Adds a catch handler.

Parameters:
exClass - Exception class
exName - Exception variable
Returns:
this

classs

public T classs()
Adds a class using this getClassSimpleName().

Returns:
this

classs

public T classs(String name)
Adds a class using the given name used primarly for inner classes.

Parameters:
name -
Returns:
this

doc

public T doc(String text)
Adds a comment line. May be used only within docBegin() and docEnd() blocks.

Parameters:
text -
Returns:
this

docAuthor

public T docAuthor(String author,
                   String... comment)
Adds an @autor tag.

Parameters:
author -
comment - Optional. If length > 0, the first element contains further comments for the author
Returns:
this

docBegin

public T docBegin()
Begins comment mode.

Returns:
this

docEnd

public T docEnd()
Ends comment mode and adds add("/").nl()

Returns:
this

docParam

public T docParam(String name,
                  String comment)

docReturn

public T docReturn(String comment)

docSee

public T docSee(Object classss,
                String method,
                Object... paramTypes)

docSingleLine

public T docSingleLine(String comment)

docThrows

public T docThrows(Object exception,
                   String comment)

complement

public T complement(Object expr)

concat

public T concat(Object... exprs)

constructor

public T constructor(Object... params)

constructorr

public T constructorr(String name,
                      Object... params)

continuee

public T continuee()

create

public T create()

decrPre

public T decrPre(Object expr)

decr

public T decr(Object expr)

defaultt

public T defaultt()

div

public T div(Object left,
             Object right)

doo

public T doo()

dot

public T dot()

elsee

public T elsee()

elseif

public T elseif(Object expr)

empty

public T empty()

end

public T end()

enumItem

public T enumItem(String name,
                  Object... params)

enumm

public T enumm()

enumm

public T enumm(String name)

enummm

public T enummm(Object... items)

enummmm

public T enummmm(String name,
                 Object... items)

eos

public T eos()

eq

public T eq(Object left,
            Object right)

expr

public ExprBase<? extends ExprBase<?>> expr()

extendss

public T extendss(Object name)

finall

public T finall()

finallyy

public T finallyy()

forr

public T forr(Object init,
              Object condition,
              Object updater)

forrr

public T forrr(Object indexFrom,
               Object indexTo)

forrr

public T forrr(Object itemClass,
               String itemName,
               Object iterable)

ge

public T ge(Object left,
            Object right)

getClasss

public Object getClasss()
Returns the full qualified name of the class that this class creates.

Returns:
Object

getPackage

public String getPackage()

getClassSimpleName

public String getClassSimpleName()

gt

public T gt(Object left,
            Object right)

iff

public T iff(Object expr)

ifff

public T ifff(Object test,
              Object trueExpr,
              Object falseExpr)

implementss

public T implementss(Object... itfs)

importAll

public void importAll(Object packagee)

importStatic

public String importStatic(Object name)

importt

public String importt(Object name)

incrPre

public T incrPre(Object expr)

incr

public T incr(Object expr)

instanceoff

public T instanceoff(Object left,
                     Object right)

interfacee

public T interfacee()

interfacee

public T interfacee(String name)

le

public T le(Object left,
            Object right)

leftShift

public T leftShift(Object left,
                   Object right)

lt

public T lt(Object left,
            Object right)

mainn

public T mainn(String... argsName)

method

public T method(Object returnType,
                String name,
                Object... params)

minus

public T minus(Object expr)

minus

public T minus(Object left,
               Object right)

ne

public T ne(Object left,
            Object right)

neww

public T neww(Object classss,
              Object... params)

next

public T next()

nl

public T nl()

not

public T not(Object expr)

or

public T or(Object left,
            Object right)

Override

public T Override()
Adds a Override annotation.

Returns:
this

packagee

public T packagee(String name)

plus

public T plus(Object expr)

plus

public T plus(Object left,
              Object right)

privatee

public T privatee()

protectedd

public T protectedd()

publicc

public T publicc()

remainder

public T remainder(Object left,
                   Object right)

returnn

public T returnn()

returnn

public T returnn(Object value)

rightShiftSigned

public T rightShiftSigned(Object left,
                          Object right)

rightShiftUnsigned

public T rightShiftUnsigned(Object left,
                            Object right)

setClasss

public void setClasss(Object classs)
Sets the full qualified name of the class that this class creates.

Parameters:
classs -

staticc

public T staticc()
Adds static.

Returns:
this

superr

public T superr(String method,
                Object... params)
Calls the given method on super.

Parameters:
method -
params -
Returns:
this

SuppressWarnings

public T SuppressWarnings(Object firstValue,
                          Object... moreValues)
Adds a SuppressWarnings annotation.

Parameters:
firstValue - First value to suppress.
moreValues - If length == 0, adds a single member annotation, else adds a normal annotation given all values in a string array.
Returns:
this

switchh

public T switchh(Object expr)
Adds a switch.

Parameters:
expr -
Returns:
this

synchronizedd

public T synchronizedd(Object expr)
Adds a synchronized.

Parameters:
expr -
Returns:
this

throwss

public T throwss(Object... exceptions)
Adds a throws declaration at the end of a ctor/method declaration.

Parameters:
exceptions - Exceptions that may be throws from the method. Must not be empty
Returns:
thhis

throww

public T throww()
Adds a throw statement.

Returns:
this

times

public T times(Object left,
               Object right)
Adds a * operation

Parameters:
left -
right -
Returns:
this.

toString

public String toString()
Returns the content added so far (tags may not be replaced yet).

Overrides:
toString in class Object

tryy

public T tryy()

var

public T var(Object classss,
             Object nameOrExpr,
             Object... init)
Adds a variable declaration (local variable, member variable, parameter...).

Example using an expression:

 var(doublee, expr().assign("d", null).next().assign("devil", 666)).eos();
 -> double d, devil = 666;
 

Example using simple names and initializers:

 var(doublee, "d").eos();
 -> double d;
 
 var(doublee, "d", 2.2).eos();
 -> double d = 2.2;
 
 var(doublee, "d", 2.2, "pi", 3.1415).eos();
 -> double d = 2.2, pi = 3.1415;
 

Parameters:
classss - Type of the variable
nameOrExpr - May be an instance of ExprBase in which case the expression is added directly and the init parameter is ignored. If not an instance of ExprBase, designates the simple name of the variable.
init - If length > 0, the first element is the variable initializer. Further elements (index > 0) must consist of [name] = [initializer] pairs.
Returns:
this

whilee

public T whilee(Object expr)
Adds a while.

Parameters:
expr -
Returns:
this

question

public T question()
Adds a question mark (?) used for wildcard type arguments.

Returns:
this

superrr

public T superrr(Object classss)
Super of the given class used for wildcard type arguments.

Example: Class<? super MyClass>

Parameters:
classss -
Returns:
this

typeArgg

public T typeArgg(Object... args)
Used to add type arguments in front of a method declaration.

Parameters:
args -
Returns:
this

getAutoImport

public boolean getAutoImport()
Returns whether to automatically import where required.

Returns:
boolean

setAutoImport

public void setAutoImport(boolean autoImport)
Sets whether to automatically import where required.

Parameters:
autoImport -

_addDefaultFileHeader

public Date _addDefaultFileHeader()
Adds the default file header.

May be overriden by subclasses to add their own header.

Returns:
The current system time

getPrettyPrint

public boolean getPrettyPrint()
Returns whether to include new lines / indent spaces to make the resulting code human readable.

This flag does not affect the javadoc methods doc*. Javadoc is always set on new lines.

Returns:
boolean

setPrettyPrint

public void setPrettyPrint(boolean prettyPrint)
Sets whether to include new lines / indent spaces to make the resulting code human readable.

This flag does not affect the javadoc methods doc*. Javadoc is always set on new lines.

Parameters:
prettyPrint -