Remove @(Not)ThreadSafe annotation
[mdsal.git] / dom / mdsal-dom-spi / src / main / java / org / opendaylight / mdsal / dom / spi / shard / SubshardProducerSpecification.java
1 /*
2  * Copyright (c) 2016 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.mdsal.dom.spi.shard;
9
10 import static java.util.Objects.requireNonNull;
11
12 import com.google.common.annotations.Beta;
13 import java.util.ArrayList;
14 import java.util.Collection;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
17 import org.opendaylight.yangtools.concepts.Mutable;
18
19 /**
20  * Specification of subshard producer context that's used for building modification factories that span into the
21  * subshards. This class is not thread-safe.
22  */
23 @Beta
24 @NonNullByDefault
25 public final class SubshardProducerSpecification implements Mutable {
26     private final Collection<DOMDataTreeIdentifier> prefixes = new ArrayList<>(1);
27     private final ChildShardContext shard;
28
29     public SubshardProducerSpecification(final ChildShardContext subshard) {
30         this.shard = requireNonNull(subshard);
31     }
32
33     public void addPrefix(final DOMDataTreeIdentifier prefix) {
34         prefixes.add(prefix);
35     }
36
37     public DOMDataTreeShardProducer createProducer() {
38         return shard.getShard().createProducer(prefixes);
39     }
40
41     public DOMDataTreeIdentifier getPrefix() {
42         return shard.getPrefix();
43     }
44 }