Package spoon.refactoring
Class MethodCallState
java.lang.Object
spoon.refactoring.MethodCallState
This class is for the call state of a method. A method can be called by
fields in a type e.g. class or by methods. Both cases are handled in this
class. For checking calls by fields use methods using CtType, for fields use
the methods using CtExecutable. A method is never called if both collections
are empty.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
add(CtExecutable<?> method)
Adds a CtExecutable to the methods invoking this method.void
Adds a CtType to the fields invoking this method.boolean
Checks the call state for the method.boolean
contains(CtExecutable<?> o)
boolean
Collection<CtType<?>>
Returns a collection containing all types invoking the method with a field.Returns a collection containing all CtExecutable invoking the method.CtExecutable<?>
Getter for the method, without saved call state.void
remove(CtExecutable<?> o)
void
-
Constructor Details
-
MethodCallState
- Parameters:
method
- for saving it's call state.
-
-
Method Details
-
add
Adds a CtExecutable to the methods invoking this method. Adding the same method again doesn't change the state.- Parameters:
method
- invoking the method.- See Also:
Collection.add(java.lang.Object)
-
add
Adds a CtType to the fields invoking this method. Adding the same CtType again doesn't change the state.- Parameters:
type
- invoking the method with an initializer.- See Also:
Collection.add(java.lang.Object)
-
getMethod
Getter for the method, without saved call state. Returns the CtExecutable and not a copy.- Returns:
- method without saved call state.
-
getCallerFields
Returns a collection containing all types invoking the method with a field. Even if a CtType invokes multiple times with different fields the method, the type is only present once. Returns the collection and not a copy. Changes to collection are directly backed in the state.- Returns:
- Collection containing all types invoking the method with a field.
-
getCallerMethods
Returns a collection containing all CtExecutable invoking the method. Even if a CtExecutable invokes multiple times the method, the CtExecutable is only present once. Returns the collection and not a copy. Changes to collection are directly backed in the state.- Returns:
- Collection containing all CtExecutable invoking the method.
-
checkCallState
public boolean checkCallState()Checks the call state for the method.- Returns:
- True if the method has no known call, false otherwise.
- See Also:
Collection.isEmpty()
-
contains
-
contains
-
remove
-
remove
-