Source:
<code>public void run(Operation operation) throws RequestException { <START> if (operation == CounterOperations.INCREMENT_AND_GET) { <END> Invocation<Long> invocation = new CounterInvocations.IncrementAndGet(counter); long currentValue = stressor.makeRequest(invocation); if (currentValue == previousValue) { throw new IllegalStateException("Inconsistent counter! Expected greater than " + previousValue); } else { previousValue = currentValue; } } else if (operation == CounterOperations.DECREMENT_AND_GET) { Invocation<Long> invocation = new CounterInvocations.DecrementAndGet(counter); long currentValue = stressor.makeRequest(invocation); if (currentValue == previousValue) { throw new IllegalStateException("Inconsistent counter! Expected lesser than " + previousValue); } else { previousValue = currentValue; } } else if (operation == CounterOperations.ADD_AND_GET) { Invocation<Long> invocation = new CounterInvocations.AddAndGet(counter, delta); long currentValue = stressor.makeRequest(invocation); if (currentValue == previousValue) { throw new IllegalStateException("Inconsistent counter! Expected value different from previous."); } else { previousValue = currentValue; } } else if (operation == CounterOperations.COMPARE_AND_SET) { long expectedValue = previousValue; long update = previousValue + 1; Invocation<Boolean> invocation = new CounterInvocations.CompareAndSet(counter, expectedValue, update); boolean success = stressor.makeRequest(invocation); if (!success) { throw new IllegalStateException("Inconsistent counter! Expected value: " + expectedValue); } else { previousValue = update; } } else throw new IllegalArgumentException(operation.name); }</code><technical_language>switch</technical_language>

Target:
public void run(Operation operation) throws RequestException { if (operation == CounterOperations.INCREMENT_AND_GET) { Invocation<Long> invocation = new CounterInvocations.IncrementAndGet(counter); long currentValue = stressor.makeRequest(invocation); if (currentValue == previousValue) { throw new IllegalStateException("Inconsistent counter! Expected greater than " + previousValue); } else { previousValue = currentValue; } } else if (operation == CounterOperations.DECREMENT_AND_GET) { Invocation<Long> invocation = new CounterInvocations.DecrementAndGet(counter); long currentValue = stressor.makeRequest(invocation); if (currentValue == previousValue) { throw new IllegalStateException("Inconsistent counter! Expected lesser than " + previousValue); } else { previousValue = currentValue; } } else if (operation == CounterOperations.ADD_AND_GET) { Invocation<Long> invocation = new CounterInvocations.AddAndGet(counter, delta); long currentValue = stressor.makeRequest(invocation); if (currentValue == previousValue) { throw new IllegalStateException("Inconsistent counter! Expected value different from previous."); } else { previousValue = currentValue; } } else if (operation == CounterOperations.COMPARE_AND_SET) { long expectedValue = previousValue; long update = previousValue + 1; Invocation<Boolean> invocation = new CounterInvocations.CompareAndSet(counter, expectedValue, update); stressor.makeRequest(invocation); previousValue = update; } else { throw new IllegalArgumentException(operation.name); } }