2 * Copyright (c) 2015 CableLabs and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.controller.packetcable.provider.validation;
11 import static com.google.common.base.Preconditions.checkNotNull;
13 import com.google.common.collect.ImmutableList;
14 import java.util.Arrays;
15 import java.util.Collection;
16 import java.util.Iterator;
21 public class ValidationException extends Exception {
23 private final ImmutableList<String> errorMessages;
25 public ValidationException(final String... errorMessages) {
26 super(concat(Arrays.asList(errorMessages)));
27 this.errorMessages = ImmutableList.copyOf(errorMessages);
30 private static String concat(Collection<String> strings) {
31 checkNotNull(strings);
33 final Iterator<String> iter = strings.iterator();
34 if (!iter.hasNext()) {
38 StringBuilder sb = new StringBuilder(iter.next());
39 while (iter.hasNext()) {
40 sb.append(" : ").append(iter.next());
46 public ValidationException(final Collection<String> errorMessages) {
47 super(concat(errorMessages));
48 this.errorMessages = ImmutableList.copyOf(errorMessages);
51 public ImmutableList<String> getErrorMessages() {