package helloworld;

import static org.requirementsascode.UseCaseModelBuilder.newBuilder;

import java.util.function.Consumer;

import org.requirementsascode.UseCaseModel;
import org.requirementsascode.UseCaseModelBuilder;
import org.requirementsascode.UseCaseModelRunner;

public class HelloWorld03_EnterNameExample extends AbstractHelloWorldExample{
	
	private static final Class<EnterText> ENTER_FIRST_NAME = EnterText.class;

	public UseCaseModel buildWith(UseCaseModelBuilder modelBuilder) {
		UseCaseModel useCaseModel = 
			modelBuilder.useCase("Get greeted")
				.basicFlow()
					.step("S1").system(promptUserToEnterFirstName())
					.step("S2").user(ENTER_FIRST_NAME).system(greetUserWithFirstName())
			.build();
		return useCaseModel;
	}
	
	private Consumer<UseCaseModelRunner> promptUserToEnterFirstName() {
		return r -> System.out.print("Please enter your first name: ");
	}
	
	private Consumer<EnterText> greetUserWithFirstName() {
		return enterText -> System.out.println("Hello, " + enterText.text + ".");
	}
	
	public static void main(String[] args){		
		HelloWorld03_EnterNameExample example = new HelloWorld03_EnterNameExample();
		example.start();
	}

	private void start() {
		UseCaseModelRunner useCaseModelRunner = new UseCaseModelRunner();
		UseCaseModel useCaseModel = buildWith(newBuilder());
		useCaseModelRunner.run(useCaseModel);
		useCaseModelRunner.reactTo(enterText());
	}
}

@@ -88,45 +88,8 @@
 r;%0A%0A
-import java.util.function.Consumer;%0A%0A
 impo
@@ -564,16 +564,22 @@
 .system(
+this::
 promptUs
@@ -592,26 +592,24 @@
 terFirstName
-()
 )%0A%09%09%09%09%09.step
@@ -645,16 +645,22 @@
 .system(
+this::
 greetUse
@@ -673,18 +673,16 @@
 irstName
-()
 )%0A%09%09%09.bu
@@ -729,82 +729,71 @@
 ate 
-Consumer%3CUseCaseModelRunner%3E promptUserToEnterFirstName() %7B%0A%09%09return r -%3E 
+void promptUserToEnterFirstName(UseCaseModelRunner runner) %7B%0A%09%09
 Syst
@@ -858,27 +858,12 @@
 ate 
-Consumer%3CEnterText%3E
+void
  gre
@@ -886,20 +886,17 @@
 ame(
-) %7B%0A%09%09return
+EnterText
  ent
@@ -905,12 +905,14 @@
 Text
- -%3E 
+) %7B%0A%09%09
 Syst

Refactor to use method references