In this section we'll define the implementation for various interfaces that we've defined in this chapter. This section is shown for completeness and can be skipped.
First, let's have a look at an implementation of the Message
interface. The message is essentially another POJO, so it will basically have getters setters and it will also override the equals
, the 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 messageKey cannot be null"); } this...