org.fuin.srcgen4javassist
Class SgMethod

java.lang.Object
  extended by org.fuin.srcgen4javassist.SgBehavior
      extended by org.fuin.srcgen4javassist.SgMethod

public final class SgMethod
extends SgBehavior

A method.


Constructor Summary
SgMethod(SgClass owner, String modifiers, SgClass returnType, String name)
          Constructor.
 
Method Summary
 void addBodyLine(String line)
          Add a new line to the body.
 List<String> getBody()
          Returns the body of the method.
 String getCallSignature()
          Returns the "call" signature of the method.
 String getName()
          Returns the name of the method.
 String getNameAsPackage()
          Returns the name of the method with an "underscore" inserted before all upper case characters and all characters converted to lower case.
 SgClass getReturnType()
          Return the return type of the method.
 String getSignature()
          Returns the "signature" of the method.
 String getTypeSignature()
          Returns the "type" signature of the method.
 String getUnderscoredNameAndTypes()
          Returns the name of the method (first character upper case) and the argument types divided by by an underscore.
 String toString()
          
 String toString(boolean showAnnotations)
          Creates the method's source with or without annotations.
 
Methods inherited from class org.fuin.srcgen4javassist.SgBehavior
addAnnotation, addAnnotations, addArgument, addException, getAnnotations, getArguments, getArguments, getCommaSeparatedArgumentNames, getCommaSeparatedArgumentNames, getExceptions, getLastArgument, getModifiers, getOwner, hasAnnotation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SgMethod

public SgMethod(SgClass owner,
                String modifiers,
                SgClass returnType,
                String name)
Constructor. The method will automatically be added to the owner.

Parameters:
owner - Class the behavior belongs to - Cannot be null.
modifiers - Modifiers for the constructor/method - Cannot be null (but empty).
returnType - Return type of the method - Cannot be null (Use VOID in model class for no return value).
name - Name of the method.
Method Detail

getReturnType

public final SgClass getReturnType()
Return the return type of the method.

Returns:
Type - Always non-null.

getBody

public final List<String> getBody()
Returns the body of the method.

Returns:
Body - Always non-null, maybe empty and is unmodifiable.

addBodyLine

public final void addBodyLine(String line)
Add a new line to the body.

Parameters:
line - Line to add - Cannot be null (but empty).

getName

public final String getName()
Returns the name of the method.

Returns:
Name - Always non-null.

getNameAsPackage

public final String getNameAsPackage()
Returns the name of the method with an "underscore" inserted before all upper case characters and all characters converted to lower case.

Returns:
Name usable as a package - Always non-null.

getSignature

public final String getSignature()
Returns the "signature" of the method.

Returns:
Modifiers, return type, name and arguments - Always non-null.

getCallSignature

public final String getCallSignature()
Returns the "call" signature of the method.

Returns:
Method name and argument names (like "methodXY(a, b, c)").

getTypeSignature

public final String getTypeSignature()
Returns the "type" signature of the method.

Returns:
Method name and argument types (like "methodXY(String, int, boolean)").

getUnderscoredNameAndTypes

public final String getUnderscoredNameAndTypes()
Returns the name of the method (first character upper case) and the argument types divided by by an underscore.

Returns:
Method name and argument types (like "MethodXY_String_int_boolean").

toString

public final String toString()

Overrides:
toString in class Object

toString

public final String toString(boolean showAnnotations)
Creates the method's source with or without annotations.

Parameters:
showAnnotations - To include annotations true else true.
Returns:
Source code of the method.


Copyright © 2011 Future Invent Informationsmanagement GmbH. All Rights Reserved.