Class MethodCallState


  • public class MethodCallState
    extends Object
    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 Detail

      • MethodCallState

        public MethodCallState​(CtExecutable<?> method)
        Parameters:
        method - for saving it's call state.
    • Method Detail

      • add

        public void add​(CtExecutable<?> method)
        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

        public void add​(CtType<?> type)
        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

        public CtExecutable<?> getMethod()
        Getter for the method, without saved call state. Returns the CtExecutable and not a copy.
        Returns:
        method without saved call state.
      • getCallerFields

        public Collection<CtType<?>> 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

        public Collection<CtExecutable<?>> 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

        public boolean contains​(CtType<?> o)
      • remove

        public void remove​(CtType<?> o)