2 * Copyright (c) 2016 Red Hat, Inc. 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.netvirt.aclservice.tests.infra;
10 import javax.inject.Inject;
11 import org.eclipse.xtext.xbase.lib.Pair;
12 import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
13 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
14 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
15 import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
16 import org.opendaylight.yangtools.yang.binding.DataObject;
17 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
20 * Utility around {@link WriteTransaction} for working with pairs and tuples of Type/Id/DataObject.
22 * <ul><li>{@link Pair}s (TODO or {@link java.util.Map.Entry} ?) of {@link InstanceIdentifier}s and
25 * {@link LogicalDatastoreType}s/InstanceIdentifiers/DataObjects
26 * <li>{@link DataTreeIdentifierDataObjectPairBuilder}
29 * @author Michael Vorburger
31 public class DataBrokerPairsUtil {
32 // TODO use, when merged, pending https://git.opendaylight.org/gerrit/#/c/46534/ (and https://git.opendaylight.org/gerrit/#/c/46479/)
34 private final WriteTransaction tx;
37 public DataBrokerPairsUtil(WriteTransaction tx) {
42 public <T extends DataObject> void put(LogicalDatastoreType type, Pair<InstanceIdentifier<T>, T> pair)
43 throws TransactionCommitFailedException {
44 tx.put(type, pair.getKey(), pair.getValue(), true);
47 public <T extends DataObject> void put(Pair<DataTreeIdentifier<T>, T> pair)
48 throws TransactionCommitFailedException {
49 tx.put(pair.getKey().getDatastoreType(), pair.getKey().getRootIdentifier(), pair.getValue(), true);
52 public <T extends DataObject> void put(DataTreeIdentifierDataObjectPairBuilder<T> builder)
53 throws TransactionCommitFailedException {