We'll now define each interface, starting with Message
that encapsulates one report message. Their implementations will be presented at the end of this chapter. Every message will have a type that can be an error or a warning, a key, and a context.
/** * represents one error/warning validation message */ public interface Message { public enum Type { ERROR, WARNING } /** * @return type of this message */ Type getType(); /** * @return key of this message */ String getMessageKey(); /** * objects in the context must be ordered from the least * specific to most specific * @return list of objects in this message's context */ List<Object> getContextOrdered(); }
Code listing 1: Message interface
The key is used for localized message lookups. The Message
interface also defines a context, which is of the List
type and can contain various objects. Objects should be ordered from least specific to most specific (the Message
interface). This...