|
Akka/Scala example source code file (Messages.java)
The Messages.java Akka example source code/** * Copyright (C) 2009-2014 Typesafe Inc. <http://www.typesafe.com> */ package docs.actor; import java.util.ArrayList; import java.util.Collections; import java.util.List; public class Messages { static //#immutable-message public class ImmutableMessage { private final int sequenceNumber; private final List<String> values; public ImmutableMessage(int sequenceNumber, List<String> values) { this.sequenceNumber = sequenceNumber; this.values = Collections.unmodifiableList(new ArrayList<String>(values)); } public int getSequenceNumber() { return sequenceNumber; } public List<String> getValues() { return values; } } //#immutable-message public static class DoIt { private final ImmutableMessage msg; DoIt(ImmutableMessage msg) { this.msg = msg; } public ImmutableMessage getMsg() { return msg; } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; DoIt doIt = (DoIt) o; if (!msg.equals(doIt.msg)) return false; return true; } @Override public int hashCode() { return msg.hashCode(); } @Override public String toString() { return "DoIt{" + "msg=" + msg + '}'; } } public static class Message { final String str; Message(String str) { this.str = str; } public String getStr() { return str; } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Message message = (Message) o; if (!str.equals(message.str)) return false; return true; } @Override public int hashCode() { return str.hashCode(); } @Override public String toString() { return "Message{" + "str='" + str + '\'' + '}'; } } public static enum Swap { Swap } public static class Result { final String x; final String s; public Result(String x, String s) { this.x = x; this.s = s; } @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((s == null) ? 0 : s.hashCode()); result = prime * result + ((x == null) ? 0 : x.hashCode()); return result; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Result other = (Result) obj; if (s == null) { if (other.s != null) return false; } else if (!s.equals(other.s)) return false; if (x == null) { if (other.x != null) return false; } else if (!x.equals(other.x)) return false; return true; } } } Other Akka source code examplesHere is a short list of links related to this Akka Messages.java source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
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.