public <R, E extends Exception> R createInProgram(ExceptionalFunction<Program, R, E> f) {
		assertNotNull("Program cannot be null", program);

		R result = null;
		boolean commit = false;
		int tx = program.startTransaction("Test");
		try {
			result = f.apply(program);
			program.flushEvents();
			waitForSwing();
			commit = true;
		}
		catch (Exception e) {
			failWithException("Exception modifying program '" + program.getName() + "'", e);
		}
		finally {
			program.endTransaction(tx, commit);
		}
		return result;
	}
Provides a convenient method for modifying the current program, handling the transaction
logic and returning a new item as a result.

@param f the function for modifying the program and creating the desired result
@return the result
Ghidra/Features/Base/src/main/java/ghidra/test/AbstractProgramBasedTest.java