Forge - Parent 1.0.5-SNAPSHOT

org.jboss.forge.parser.java.impl
Class MethodImpl<O extends JavaSource<O>>

java.lang.Object
  extended by org.jboss.forge.parser.java.impl.MethodImpl<O>
All Implemented Interfaces:
Internal, Abstractable<Method<O>>, AnnotationTarget<O,Method<O>>, Member<O,Method<O>>, Method<O>, VisibilityScoped<Method<O>>, Origin<O>

public class MethodImpl<O extends JavaSource<O>>
extends Object
implements Method<O>

Author:
Lincoln Baxter, III

Constructor Summary
MethodImpl(O parent)
           
MethodImpl(O parent, Object internal)
           
MethodImpl(O parent, String method)
           
 
Method Summary
 Annotation<O> addAnnotation()
          Add a new annotation instance to this T.
 Annotation<O> addAnnotation(Class<? extends Annotation> clazz)
          Add a new annotation instance to this T, using the given Class as the annotation type.
 Annotation<O> addAnnotation(String className)
          Add a new annotation instance to this T, using the given String className as the annotation type.
 Method<O> addThrows(Class<? extends Exception> type)
          Add a thrown Exception to this method's signature.
 Method<O> addThrows(String type)
          Add a thrown Exception to this method's signature.
 boolean equals(Object obj)
           
 Annotation<O> getAnnotation(Class<? extends Annotation> type)
           
 Annotation<O> getAnnotation(String type)
           
 List<Annotation<O>> getAnnotations()
           
 String getBody()
          Get the inner body of this Method
 Object getInternal()
          Returns the implementation-specific Object representing this.
 String getName()
           
 O getOrigin()
           
 List<Parameter> getParameters()
          Get a list of this Method's parameters.
 String getQualifiedReturnType()
          Get the fully qualified return type of this Method or return null if the return type is void.
 String getReturnType()
          Get the return type of this Method or return null if the return type is void.
 Type<O> getReturnTypeInspector()
          Get the return Type of this Method or return null if the return type is void.
 List<String> getThrownExceptions()
          Get a list of qualified (if possible) Exception class names thrown by this method.
 Visibility getVisibility()
           
 boolean hasAnnotation(Class<? extends Annotation> type)
           
 boolean hasAnnotation(String type)
           
 int hashCode()
           
 boolean isAbstract()
           
 boolean isConstructor()
          Return true if this Method is a constructor for the class in which it is defined.
 boolean isFinal()
           
 boolean isPackagePrivate()
           
 boolean isPrivate()
           
 boolean isProtected()
           
 boolean isPublic()
           
 boolean isReturnTypeVoid()
          Return true if this Method has a return type of 'void'
 boolean isStatic()
           
 Method<O> removeAnnotation(Annotation<O> annotation)
           
 Method<O> removeThrows(Class<? extends Exception> type)
          Remove a thrown Exception to this method's signature.
 Method<O> removeThrows(String type)
          Remove a thrown Exception to this method's signature.
 Method<O> setAbstract(boolean abstrct)
           
 Method<O> setBody(String body)
          Set the inner body of this Method
 Method<O> setConstructor(boolean constructor)
          Toggle this method as a constructor.
 Method<O> setFinal(boolean finl)
           
 Method<O> setName(String name)
          Set the name of this Method
 Method<O> setPackagePrivate()
           
 Method<O> setParameters(String parameters)
          Set this Method's parameters.
 Method<O> setPrivate()
           
 Method<O> setProtected()
           
 Method<O> setPublic()
           
 Method<O> setReturnType(Class<?> type)
          Set this Method to return the given type.
 Method<O> setReturnType(JavaSource<?> type)
          Set this Method to return the given JavaSource type.
 Method<O> setReturnType(String typeName)
          Set this Method to return the given type.
 Method<O> setReturnTypeVoid()
          Set this Method to return 'void'
 Method<O> setStatic(boolean statc)
           
 Method<O> setVisibility(Visibility scope)
           
 String toSignature()
          Convert this Method into a string representing its unique signature.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MethodImpl

public MethodImpl(O parent)

MethodImpl

public MethodImpl(O parent,
                  Object internal)

MethodImpl

public MethodImpl(O parent,
                  String method)
Method Detail

toSignature

public String toSignature()
Description copied from interface: Method
Convert this Method into a string representing its unique signature.

Specified by:
toSignature in interface Method<O extends JavaSource<O>>

addAnnotation

public Annotation<O> addAnnotation()
Description copied from interface: AnnotationTarget
Add a new annotation instance to this T. (Note that an import statement must be added manually if required.)

Specified by:
addAnnotation in interface AnnotationTarget<O extends JavaSource<O>,Method<O extends JavaSource<O>>>

addAnnotation

public Annotation<O> addAnnotation(Class<? extends Annotation> clazz)
Description copied from interface: AnnotationTarget
Add a new annotation instance to this T, using the given Class as the annotation type. Attempt to add an import statement to this object's O if required.

Specified by:
addAnnotation in interface AnnotationTarget<O extends JavaSource<O>,Method<O extends JavaSource<O>>>

addAnnotation

public Annotation<O> addAnnotation(String className)
Description copied from interface: AnnotationTarget
Add a new annotation instance to this T, using the given String className as the annotation type. Attempt to add an import statement to this object's O if required. (Note that the given className must be fully-qualified in order to properly import required classes)

Specified by:
addAnnotation in interface AnnotationTarget<O extends JavaSource<O>,Method<O extends JavaSource<O>>>

getAnnotations

public List<Annotation<O>> getAnnotations()
Specified by:
getAnnotations in interface AnnotationTarget<O extends JavaSource<O>,Method<O extends JavaSource<O>>>

hasAnnotation

public boolean hasAnnotation(Class<? extends Annotation> type)
Specified by:
hasAnnotation in interface AnnotationTarget<O extends JavaSource<O>,Method<O extends JavaSource<O>>>

hasAnnotation

public boolean hasAnnotation(String type)
Specified by:
hasAnnotation in interface AnnotationTarget<O extends JavaSource<O>,Method<O extends JavaSource<O>>>

removeAnnotation

public Method<O> removeAnnotation(Annotation<O> annotation)
Specified by:
removeAnnotation in interface AnnotationTarget<O extends JavaSource<O>,Method<O extends JavaSource<O>>>

getAnnotation

public Annotation<O> getAnnotation(Class<? extends Annotation> type)
Specified by:
getAnnotation in interface AnnotationTarget<O extends JavaSource<O>,Method<O extends JavaSource<O>>>

getAnnotation

public Annotation<O> getAnnotation(String type)
Specified by:
getAnnotation in interface AnnotationTarget<O extends JavaSource<O>,Method<O extends JavaSource<O>>>

getBody

public String getBody()
Description copied from interface: Method
Get the inner body of this Method

Specified by:
getBody in interface Method<O extends JavaSource<O>>

setBody

public Method<O> setBody(String body)
Description copied from interface: Method
Set the inner body of this Method

Specified by:
setBody in interface Method<O extends JavaSource<O>>

setConstructor

public Method<O> setConstructor(boolean constructor)
Description copied from interface: Method
Toggle this method as a constructor. If true, and the name of the Method is not the same as the name of its parent JavaClass , update the name of the to match.

Specified by:
setConstructor in interface Method<O extends JavaSource<O>>

isConstructor

public boolean isConstructor()
Description copied from interface: Method
Return true if this Method is a constructor for the class in which it is defined.

Specified by:
isConstructor in interface Method<O extends JavaSource<O>>

getReturnType

public String getReturnType()
Description copied from interface: Method
Get the return type of this Method or return null if the return type is void.

Specified by:
getReturnType in interface Method<O extends JavaSource<O>>

getQualifiedReturnType

public String getQualifiedReturnType()
Description copied from interface: Method
Get the fully qualified return type of this Method or return null if the return type is void.

Specified by:
getQualifiedReturnType in interface Method<O extends JavaSource<O>>

getReturnTypeInspector

public Type<O> getReturnTypeInspector()
Description copied from interface: Method
Get the return Type of this Method or return null if the return type is void.

Specified by:
getReturnTypeInspector in interface Method<O extends JavaSource<O>>

setReturnType

public Method<O> setReturnType(Class<?> type)
Description copied from interface: Method
Set this Method to return the given type.

Specified by:
setReturnType in interface Method<O extends JavaSource<O>>

setReturnType

public Method<O> setReturnType(String typeName)
Description copied from interface: Method
Set this Method to return the given type.

Specified by:
setReturnType in interface Method<O extends JavaSource<O>>

setReturnType

public Method<O> setReturnType(JavaSource<?> type)
Description copied from interface: Method
Set this Method to return the given JavaSource type.

Specified by:
setReturnType in interface Method<O extends JavaSource<O>>

isReturnTypeVoid

public boolean isReturnTypeVoid()
Description copied from interface: Method
Return true if this Method has a return type of 'void'

Specified by:
isReturnTypeVoid in interface Method<O extends JavaSource<O>>

setReturnTypeVoid

public Method<O> setReturnTypeVoid()
Description copied from interface: Method
Set this Method to return 'void'

Specified by:
setReturnTypeVoid in interface Method<O extends JavaSource<O>>

isAbstract

public boolean isAbstract()
Specified by:
isAbstract in interface Abstractable<Method<O extends JavaSource<O>>>

setAbstract

public Method<O> setAbstract(boolean abstrct)
Specified by:
setAbstract in interface Abstractable<Method<O extends JavaSource<O>>>

isFinal

public boolean isFinal()
Specified by:
isFinal in interface Member<O extends JavaSource<O>,Method<O extends JavaSource<O>>>

setFinal

public Method<O> setFinal(boolean finl)
Specified by:
setFinal in interface Member<O extends JavaSource<O>,Method<O extends JavaSource<O>>>

isStatic

public boolean isStatic()
Specified by:
isStatic in interface Member<O extends JavaSource<O>,Method<O extends JavaSource<O>>>

setStatic

public Method<O> setStatic(boolean statc)
Specified by:
setStatic in interface Member<O extends JavaSource<O>,Method<O extends JavaSource<O>>>

getName

public String getName()
Specified by:
getName in interface Member<O extends JavaSource<O>,Method<O extends JavaSource<O>>>

setName

public Method<O> setName(String name)
Description copied from interface: Method
Set the name of this Method

Specified by:
setName in interface Method<O extends JavaSource<O>>

setParameters

public Method<O> setParameters(String parameters)
Description copied from interface: Method
Set this Method's parameters.

Specified by:
setParameters in interface Method<O extends JavaSource<O>>

getParameters

public List<Parameter> getParameters()
Description copied from interface: Method
Get a list of this Method's parameters.

Specified by:
getParameters in interface Method<O extends JavaSource<O>>

isPackagePrivate

public boolean isPackagePrivate()
Specified by:
isPackagePrivate in interface VisibilityScoped<Method<O extends JavaSource<O>>>

setPackagePrivate

public Method<O> setPackagePrivate()
Specified by:
setPackagePrivate in interface VisibilityScoped<Method<O extends JavaSource<O>>>

isPublic

public boolean isPublic()
Specified by:
isPublic in interface VisibilityScoped<Method<O extends JavaSource<O>>>

setPublic

public Method<O> setPublic()
Specified by:
setPublic in interface VisibilityScoped<Method<O extends JavaSource<O>>>

isPrivate

public boolean isPrivate()
Specified by:
isPrivate in interface VisibilityScoped<Method<O extends JavaSource<O>>>

setPrivate

public Method<O> setPrivate()
Specified by:
setPrivate in interface VisibilityScoped<Method<O extends JavaSource<O>>>

isProtected

public boolean isProtected()
Specified by:
isProtected in interface VisibilityScoped<Method<O extends JavaSource<O>>>

setProtected

public Method<O> setProtected()
Specified by:
setProtected in interface VisibilityScoped<Method<O extends JavaSource<O>>>

getVisibility

public Visibility getVisibility()
Specified by:
getVisibility in interface VisibilityScoped<Method<O extends JavaSource<O>>>

setVisibility

public Method<O> setVisibility(Visibility scope)
Specified by:
setVisibility in interface VisibilityScoped<Method<O extends JavaSource<O>>>

toString

public String toString()
Overrides:
toString in class Object

getInternal

public Object getInternal()
Description copied from interface: Internal
Returns the implementation-specific Object representing this. Do not call this method unless you are willing to risk breaking backwards compatibility if future versions do not use the same internal object implementations.

Specified by:
getInternal in interface Internal

getOrigin

public O getOrigin()
Specified by:
getOrigin in interface Origin<O extends JavaSource<O>>
Returns:
the instance of the root ancestor.

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

addThrows

public Method<O> addThrows(Class<? extends Exception> type)
Description copied from interface: Method
Add a thrown Exception to this method's signature.

Specified by:
addThrows in interface Method<O extends JavaSource<O>>

addThrows

public Method<O> addThrows(String type)
Description copied from interface: Method
Add a thrown Exception to this method's signature.

Specified by:
addThrows in interface Method<O extends JavaSource<O>>

getThrownExceptions

public List<String> getThrownExceptions()
Description copied from interface: Method
Get a list of qualified (if possible) Exception class names thrown by this method.

Specified by:
getThrownExceptions in interface Method<O extends JavaSource<O>>

removeThrows

public Method<O> removeThrows(Class<? extends Exception> type)
Description copied from interface: Method
Remove a thrown Exception to this method's signature.

Specified by:
removeThrows in interface Method<O extends JavaSource<O>>

removeThrows

public Method<O> removeThrows(String type)
Description copied from interface: Method
Remove a thrown Exception to this method's signature.

Specified by:
removeThrows in interface Method<O extends JavaSource<O>>

Forge - Parent 1.0.5-SNAPSHOT

Copyright © 2012 JBoss, a division of Red Hat, Inc.. All Rights Reserved.