aboutsummaryrefslogtreecommitdiffstats
path: root/config-model/src/main/java/com/yahoo/schema/DocumentReferences.java
blob: a39df8636d6428d1416c1722814f4f1aeb93187e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.schema;

import java.util.Collections;
import java.util.Iterator;
import java.util.Map;
import java.util.stream.Stream;

/**
 * Contains all document references for a document mapped by field name
 *
 * @author bjorncs
 */
public class DocumentReferences implements Iterable<Map.Entry<String, DocumentReference>> {
    private final Map<String, DocumentReference> references;

    public DocumentReferences(Map<String, DocumentReference> references) {
        this.references = references;
    }

    public void mergeFrom(DocumentReferences other) {
        references.putAll(other.references);
    }

    @Override
    public Iterator<Map.Entry<String, DocumentReference>> iterator() {
        return Collections.unmodifiableSet(references.entrySet()).iterator();
    }

    public Map<String, DocumentReference> referenceMap() {
        return Collections.unmodifiableMap(references);
    }

    public Stream<Map.Entry<String, DocumentReference>> stream() {
        return references.entrySet().stream();
    }
}