2 * Copyright (c) 2020 PANTHEON.tech, s.r.o. 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
8 package org.opendaylight.yangtools.yang.data.api.schema.tree;
10 import static java.util.Objects.requireNonNull;
12 import com.google.common.annotations.Beta;
13 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
14 import java.util.Collections;
16 import org.eclipse.jdt.annotation.NonNullByDefault;
17 import org.eclipse.jdt.annotation.Nullable;
18 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
19 import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Descendant;
22 * Exception thrown when a {@code unique} statement restrictions are violated.
24 * @author Robert Varga
28 public class UniqueConstraintException extends DataValidationFailedException {
29 private static final long serialVersionUID = 1L;
31 // Note: this cannot be an ImmutableMap because we must support null values
32 @SuppressFBWarnings(value = "SE_BAD_FIELD", justification = "Best effort on serialization")
33 private final Map<Descendant, @Nullable Object> values;
35 public UniqueConstraintException(final YangInstanceIdentifier path, final Map<Descendant, @Nullable Object> values,
36 final String message) {
38 this.values = requireNonNull(values);
41 public final Map<Descendant, @Nullable Object> values() {
42 return Collections.unmodifiableMap(values);