org.fuin.srcgen4javassist
Class SgBehavior

java.lang.Object
  extended by org.fuin.srcgen4javassist.SgBehavior
Direct Known Subclasses:
SgConstructor, SgMethod

public abstract class SgBehavior
extends Object

Base class for constructors and methods.


Constructor Summary
SgBehavior(SgClass owner, String modifiers)
          Constructor with class and modifiers.
 
Method Summary
 void addAnnotation(SgAnnotation annotation)
          Adds an annotation.
 void addAnnotations(List<SgAnnotation> annotations)
          Adds a list of annotations.
 void addArgument(SgArgument arg)
          Adds an argument to the list.
 void addException(SgClass clasz)
          Adds an exception to the list.
 List<SgAnnotation> getAnnotations()
          Returns the annotations for this method.
 List<SgArgument> getArguments()
          Returns the constructor/method arguments.
 List<SgArgument> getArguments(int less)
          Returns the arguments from 0..
 String getCommaSeparatedArgumentNames()
          Returns the argument names separated by a comma.
 String getCommaSeparatedArgumentNames(int less)
          Returns the argument names from 0..
 List<SgClass> getExceptions()
          Returns the list of exceptions thrown by the constructor/method.
 SgArgument getLastArgument()
          Returns the last argument of the list.
 String getModifiers()
          Returns the modifiers for the constructor/method.
 SgClass getOwner()
          Returns the class the behavior belongs to.
 boolean hasAnnotation(String name)
          Checks if a given annotation is in the list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SgBehavior

public SgBehavior(SgClass owner,
                  String modifiers)
Constructor with class and modifiers.

Parameters:
owner - Class the behavior belongs to - Cannot be null.
modifiers - Modifiers for the constructor/method - Cannot be null (but empty).
Method Detail

getOwner

public final SgClass getOwner()
Returns the class the behavior belongs to.

Returns:
Owner - Always non-null.

getModifiers

public final String getModifiers()
Returns the modifiers for the constructor/method.

Returns:
Modifiers (space separated) - Always non-null (but maybe empty).

getArguments

public final List<SgArgument> getArguments()
Returns the constructor/method arguments.

Returns:
Arguments - Always non-null and is unmodifiable.

getCommaSeparatedArgumentNames

public final String getCommaSeparatedArgumentNames(int less)
Returns the argument names from 0..(N+less) separated by a comma.

Parameters:
less - The number of arguments NOT to return from the end of the list. It's always a NEGATIVE value.
Returns:
Arguments without "less" arguments at the end of the list.

getCommaSeparatedArgumentNames

public final String getCommaSeparatedArgumentNames()
Returns the argument names separated by a comma.

Returns:
Arguments.

getArguments

public final List<SgArgument> getArguments(int less)
Returns the arguments from 0..(N+less).

Parameters:
less - The number of arguments NOT to return from the end of the list. It's always a NEGATIVE value.
Returns:
Unmodifiable argument list without "less" arguments at the end of the list.

getLastArgument

public final SgArgument getLastArgument()
Returns the last argument of the list.

Returns:
Last argument or null if the list is empty.

addArgument

public final void addArgument(SgArgument arg)
Adds an argument to the list. Does nothing if the argument is already in the list of arguments. You will never need to use this method in your code! An argument is added automatically to the owning behavior when it's constructed!

Parameters:
arg - Argument to add - Non null.

getExceptions

public final List<SgClass> getExceptions()
Returns the list of exceptions thrown by the constructor/method.

Returns:
List of exceptions - Always non-null and is unmodifiable.

addException

public final void addException(SgClass clasz)
Adds an exception to the list. Does nothing if the class is already in the list of exceptions.

Parameters:
clasz - Exception to add.

getAnnotations

public final List<SgAnnotation> getAnnotations()
Returns the annotations for this method.

Returns:
List of annotations - Always non-null and is unmodifiable

addAnnotation

public final void addAnnotation(SgAnnotation annotation)
Adds an annotation.

Parameters:
annotation - Annotation to add - Cannot be null.

addAnnotations

public final void addAnnotations(List<SgAnnotation> annotations)
Adds a list of annotations. The internal list will not be cleared! The annotations will simply be added with addAll(..).

Parameters:
annotations - Annotations to add - Cannot be null.

hasAnnotation

public final boolean hasAnnotation(String name)
Checks if a given annotation is in the list.

Parameters:
name - Name of the annotation to find - Cannot be null.
Returns:
If it's found true else false.


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