In this section, we'll define the implementation for various interfaces that we've defined in this chapter. You can skip this section if you like. It is here for completeness.
First, let's look at an implementation of the Message
interface, which is shown in the following code. The message is essentially another POJO, so it will basically have get
and set
methods, and it will also override the equals
, hashCode
, and toString
methods.
import org.apache.commons.lang.builder.EqualsBuilder; import org.apache.commons.lang.builder.HashCodeBuilder; import org.apache.commons.lang.builder.ToStringBuilder; //... other imports public class DefaultMessage implements Message, Serializable { private Message.Type type; private String messageKey; private List<Object> context; public DefaultMessage(Message.Type type, String messageKey, List<Object> context) { if (type == null || messageKey == null) { throw new IllegalArgumentException( "Type and...