Do not pretty-print body class
[yangtools.git] / data / yang-data-api / src / main / java / org / opendaylight / yangtools / yang / data / api / schema / DuplicateEntry.java
1 /*
2  * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
3  *
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
7  */
8 package org.opendaylight.yangtools.yang.data.api.schema;
9
10 import java.util.ArrayList;
11 import java.util.Collections;
12 import java.util.List;
13 import org.opendaylight.yangtools.concepts.Identifiable;
14 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
15
16 /**
17  * Entry describing a duplicate found in a {@link NormalizedNode} tree. Note this
18  * class leaks mutable collections, so users are advised either not to share it.
19  */
20 public final class DuplicateEntry implements Identifiable<YangInstanceIdentifier> {
21     private final List<YangInstanceIdentifier> hardLinks = new ArrayList<>(1);
22     private List<YangInstanceIdentifier> duplicates = Collections.emptyList();
23
24     DuplicateEntry(final YangInstanceIdentifier path) {
25         hardLinks.add(path);
26     }
27
28     void addDuplicate(final YangInstanceIdentifier path) {
29         if (duplicates.isEmpty()) {
30             duplicates = new ArrayList<>();
31         }
32         duplicates.add(path);
33     }
34
35     void addHardLink(final YangInstanceIdentifier path) {
36         hardLinks.add(path);
37     }
38
39     @Override
40     public YangInstanceIdentifier getIdentifier() {
41         return hardLinks.get(0);
42     }
43
44     public List<YangInstanceIdentifier> getHardLinks() {
45         return hardLinks;
46     }
47
48     public List<YangInstanceIdentifier> getDuplicates() {
49         return duplicates;
50     }
51 }