private static <T> InvariantViolationException failed( final T value, final Violations violations) { final StringBuilder sb = new StringBuilder(128); sb.append("Invariant violation."); sb.append(System.lineSeparator()); sb.append(" Received: "); sb.append(value); sb.append(System.lineSeparator()); sb.append(" Violated conditions: "); sb.append(System.lineSeparator()); final String[] messages = violations.messages(); for (int index = 0; index < messages.length; ++index) { if (messages[index] != null) { sb.append(" ["); sb.append(index); sb.append("]: "); sb.append(messages[index]); sb.append(System.lineSeparator()); } } throw new InvariantViolationException(sb.toString(), violations.count()); } }
private static <T> InvariantViolationException failed( final T value, final Violations violations) { final StringBuilder sb = new StringBuilder(128); sb.append("Invariant violation."); sb.append(System.lineSeparator()); sb.append(" Received: "); sb.append(value); sb.append(System.lineSeparator()); sb.append(" Violated conditions: "); sb.append(System.lineSeparator()); final String[] messages = violations.messages(); for (int index = 0; index < messages.length; ++index) { if (messages[index] != null) { sb.append(" ["); sb.append(index); sb.append("]: "); sb.append(messages[index]); sb.append(System.lineSeparator()); } } throw new InvariantViolationException(sb.toString(), violations.count()); } }