# Class PerformRefactoringOperation

java.lang.Object
org.eclipse.ltk.core.refactoring.PerformRefactoringOperation

All Implemented Interfaces:
  `IWorkspaceRunnable, ICoreRunnable`

public class PerformRefactoringOperation extends Object implements IWorkspaceRunnable
Operation that, when run, executes a refactoring. This includes condition checking, change creation, change execution and remembering of the undo change on the refactoring's undo stack.

The operation should be executed via the run method offered by `IWorkspace` to achieve proper delta batching.

Note: this class is not intended to be extended by clients.

Since:
  3.0
See Also:
  - `IWorkspace`
Restriction:
  This class is not intended to be subclassed by clients.

## Constructor Summary

Constructors
Constructor
Description
`PerformRefactoringOperation(RefactoringContext refactoringContext, int style)`
Create a new perform refactoring operation.
`PerformRefactoringOperation(Refactoring refactoring, int style)`
Create a new perform refactoring operation.

## Method Summary

Modifier and Type
Method
Description
`RefactoringStatus`
`getConditionStatus()`
Return the refactoring status of the condition checking.
`Change`
`getUndoChange()`
The undo object or `null` if no undo exists.
`RefactoringStatus`
`getValidationStatus()`
Returns the refactoring status of the change's validation checking or `null` if a change couldn't be created or the operation hasn't been performed yet.
`void`
`run(IProgressMonitor monitor)`
Executes this runnable.

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### PerformRefactoringOperation

public PerformRefactoringOperation(Refactoring refactoring, int style)
Create a new perform refactoring operation. The operation will not perform the refactoring if the refactoring's condition checking returns an error of severity `RefactoringStatus.FATAL`.

Parameters:
  `refactoring` - the refactoring to perform
  `style` - the condition checking style as defined by `CheckConditionsOperation`
See Also:
  - `PerformRefactoringOperation(RefactoringContext, int)`

### PerformRefactoringOperation

public PerformRefactoringOperation(RefactoringContext refactoringContext, int style)
Create a new perform refactoring operation. The operation will not perform the refactoring if the refactoring's condition checking returns an error of severity `RefactoringStatus.FATAL`.

The caller must ensure that the operation is run exactly once. The implementation of `run(IProgressMonitor)` will call `RefactoringContext.dispose()`.

Parameters:
  `refactoringContext` - the refactoring context to perform
  `style` - the condition checking style as defined by `CheckConditionsOperation`
Since:
  3.6

## Method Details

### getConditionStatus

public RefactoringStatus getConditionStatus()
Return the refactoring status of the condition checking.

Returns:
  the refactoring status of the condition checking or `null` if the operation hasn't been performed yet

### getValidationStatus

public RefactoringStatus getValidationStatus()
Returns the refactoring status of the change's validation checking or `null` if a change couldn't be created or the operation hasn't been performed yet.

Returns:
  the refactoring status of the change's validation checking

### getUndoChange

public Change getUndoChange()
The undo object or `null` if no undo exists. The undo object is initialize via the call `Change.initializeValidationData(IProgressMonitor)`

Returns:
  the undo object or `null`

### run

public void run(IProgressMonitor monitor) throws CoreException
Description copied from interface: `ICoreRunnable`
Executes this runnable.

The provided monitor can be used to report progress and respond to cancellation. If the progress monitor has been canceled, the runnable should finish its execution at the earliest convenience and throw an `OperationCanceledException`. A `CoreException` with a status of severity `IStatus.CANCEL` has the same effect as an `OperationCanceledException`.

Specified by:
  `run` in interface `ICoreRunnable`
Specified by:
  `run` in interface `IWorkspaceRunnable`
Parameters:
  `monitor` - a progress monitor, or `null` if progress reporting and cancellation are not desired. The monitor is only valid for the duration of the invocation of this method. Callers may call `IProgressMonitor.done()` after this method returns or throws an exception, but this is not strictly required.
Throws:
  `CoreException` - if this operation fails