package actor;

import java.util.Optional;

import org.requirementsascode.AbstractActor;
import org.requirementsascode.Model;

import actor.message.EnterName;

public class PublishingActorExample {
	public static void main(String[] args) {
		AbstractActor actor = new PublishingActor(); 
		
		Optional<Object> userName = actor.reactTo(new EnterName("Joe"));	
		System.out.println("Your name is: " + userName.get() + ".");
	}
}

class PublishingActor extends AbstractActor {
  @Override
  public Model behavior() {
    Model model = Model.builder()
      .user(EnterName.class).systemPublish(this::publishNameAsString)
      .on(String.class).system(this::displayNameString)
    .build();
    return model;
  }

  private String publishNameAsString(EnterName enterName) {
    return enterName.getUserName();
  }

  public void displayNameString(String nameString) {
    System.out.println("Welcome, " + nameString + ".");
  }
}


@@ -191,17 +191,18 @@
 ample %7B%0A
-%09
+  
 public s
@@ -234,18 +234,20 @@
 args) %7B%0A
-%09%09
+    
 Abstract
@@ -286,15 +286,14 @@
 r();
- %0A%09%09%0A%09%09
+%0A%0A    
 Opti
@@ -356,12 +356,13 @@
 %22));
-%09%0A%09%09
+%0A    
 Syst
@@ -422,9 +422,10 @@
 %22);%0A
-%09
+  
 %7D%0A%7D%0A

Improve formatting