alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Akka/Scala example source code file (Events.java)

This example Akka source code file (Events.java) is included in my "Source Code Warehouse" project. The intent of this project is to help you more easily find Akka and Scala source code examples by using tags.

All credit for the original source code belongs to akka.io; I'm just trying to make examples easier to find. (For my Scala work, see my Scala examples and tutorials.)

Akka tags/keywords

actor, actorref, akka, batch, flush, list, object, override, queue, settarget, string, stringbuilder

The Events.java Akka example source code

/**
 * Copyright (C) 2009-2014 Typesafe Inc. <http://www.typesafe.com>
 */

package docs.actor.fsm;

import akka.actor.ActorRef;
import java.util.List;

public class Events {

  static
  //#simple-events
  public final class SetTarget {
    private final ActorRef ref;

    public SetTarget(ActorRef ref) {
      this.ref = ref;
    }

    public ActorRef getRef() {
      return ref;
    }
    //#boilerplate

    @Override
    public String toString() {
      return "SetTarget{" +
        "ref=" + ref +
        '}';
    }
    //#boilerplate
  }

  //#simple-events
  static
  //#simple-events
  public final class Queue {
    private final Object obj;

    public Queue(Object obj) {
      this.obj = obj;
    }

    public Object getObj() {
      return obj;
    }
    //#boilerplate

    @Override
    public String toString() {
      return "Queue{" +
        "obj=" + obj +
        '}';
    }
    //#boilerplate
  }

  //#simple-events
  static
  //#simple-events
  public final class Batch {
    private final List<Object> list;

    public Batch(List<Object> list) {
      this.list = list;
    }

    public List<Object> getList() {
      return list;
    }
    //#boilerplate

    @Override
    public boolean equals(Object o) {
      if (this == o) return true;
      if (o == null || getClass() != o.getClass()) return false;

      Batch batch = (Batch) o;

      return list.equals(batch.list);
    }

    @Override
    public int hashCode() {
      return list.hashCode();
    }

    @Override
    public String toString() {
      final StringBuilder builder = new StringBuilder();
      builder.append( "Batch{list=");
      list.stream().forEachOrdered(e -> { builder.append(e); builder.append(","); });
      int len = builder.length();
      builder.replace(len, len, "}");
      return builder.toString();
    }
    //#boilerplate
  }

  //#simple-events
  static
  //#simple-events
  public enum Flush {
    Flush
  }
  //#simple-events
}

Other Akka source code examples

Here is a short list of links related to this Akka Events.java source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.