public Collection<ValidationMessage> validate(final MessageInterface messageInterface) {
   final List<ValidationMessage> messages = new LinkedList<ValidationMessage>();
   for (ValidIdRange validIdRange : messageInterface.validIdRanges()) {
     if (validIdRange.min() > validIdRange.max()) {
       messages.add(
           createError(
               messageInterface,
               "Minimum id value (%d) cannot be greater than the maximum value (%d).",
               validIdRange.min(),
               validIdRange.max()));
     } else {
       final Map<ValidIdRange, MessageInterface> processed = getProcessed(messageInterface);
       for (Entry<ValidIdRange, MessageInterface> entry : processed.entrySet()) {
         final ValidIdRange vid = entry.getKey();
         if (overlap(validIdRange, vid)) {
           messages.add(
               createError(
                   messageInterface,
                   "@ValidIdRange min/max (%d/%d) overlap the range (%d/%d) on '%s'.",
                   validIdRange.min(),
                   validIdRange.max(),
                   vid.min(),
                   vid.max(),
                   entry.getValue().name()));
         }
       }
       final MessageInterface previous = processed.put(validIdRange, messageInterface);
       if (previous != null) {
         messages.add(
             createError(
                 messageInterface, "%s was used on %s", validIdRange, messageInterface.name()));
       }
     }
   }
   return messages;
 }
 private boolean overlap(final ValidIdRange r1, final ValidIdRange r2) {
   return (r1.min() >= r2.min() && r1.min() <= r2.max())
       || (r1.max() >= r2.min() && r1.max() <= r2.max())
       || (r2.min() >= r1.min() && r2.min() <= r1.max())
       || (r2.max() >= r1.min() && r2.max() <= r1.max());
 }