/** * Answers a new ActorAgent with Actor type, Address, and Mailbox state. * @param anActorType the Class<? extends Actor> of the concrete Actor * @param anActor the Actor instance * @return ActorAgent */ protected ActorAgent actorAgentFor(Class<? extends Actor> anActorType, Actor anActor) { ActorKeyValueTypeElement typeElement = this.typeElementFor(anActorType); ActorAgent actorAgent = this.actorAgentFactory() .newActorAgentFor(this, anActorType, anActor, typeElement.mailbox()); return actorAgent; }
/** * @see co.vaughnvernon.actormodel.actor.ActorFinder#findActorAgentBy(java.lang.Class, co.vaughnvernon.actormodel.actor.Query) */ @Override public ActorAgent findFirstMatching( Class<? extends Actor> anActorType, Query aQuery) { ActorKeyValueTypeElement typeElement = this.typeElementFor(anActorType); for (Actor actor : typeElement.store().values()) { if (actor.matches(aQuery)) { ActorAgent actorAgent = this.actorAgentFactory() .newActorAgentFor(this, anActorType, actor, typeElement.mailbox()); return actorAgent; } } return null; }