String (@NotNull Context context) { ArrayList<String> registeredVars = new ArrayList<>(context.myRegisteredVars); String flatMapVar = context.registerSourceVar(); String code = ".flatMap( " + flatMapVar + " -> " + context.generateOptionalCall(false) + ")"; context.myRegisteredVars = registeredVars; return code; }