com.github.euler.core.EulerState Maven / Gradle / Ivy
package com.github.euler.core;
import akka.actor.typed.ActorRef;
public class EulerState {
private ActorRef replyTo;
private boolean discoveryFinishedOrFailed = false;
private int items = 0;
private ProcessingContext ctx = ProcessingContext.EMPTY;
public void onMessage(JobToProcess msg) {
this.replyTo = msg.replyTo;
this.ctx = msg.ctx;
}
public void onMessage(ScanFinished msg) {
this.discoveryFinishedOrFailed = true;
}
public void onMessage(JobItemFound msg) {
this.items++;
}
public void onMessage(ScanFailed msg) {
this.discoveryFinishedOrFailed = true;
}
public void onMessage(JobItemProcessed msg) {
this.items--;
}
public boolean isProcessed() {
return this.items == 0 && this.discoveryFinishedOrFailed;
}
public ActorRef getReplyTo() {
return replyTo;
}
public ProcessingContext getCtx() {
return ctx;
}
}