2 * Copyright (c) 2018 Pantheon Technologies, 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.mdsal.dom.api;
10 import static com.google.common.base.Preconditions.checkArgument;
11 import static java.util.Objects.requireNonNull;
13 import com.google.common.base.MoreObjects;
14 import com.google.common.collect.ImmutableSet;
15 import java.util.Objects;
17 import org.eclipse.jdt.annotation.Nullable;
18 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
19 import org.opendaylight.yangtools.concepts.Immutable;
20 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
21 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
24 * An action which is subject to availability.
26 public final class DOMActionInstance implements Immutable {
27 private final Set<DOMDataTreeIdentifier> dataTrees;
28 private final SchemaPath type;
30 DOMActionInstance(final SchemaPath type, final Set<DOMDataTreeIdentifier> dataTrees) {
31 this.type = requireNonNull(type);
32 this.dataTrees = ImmutableSet.copyOf(dataTrees);
33 checkArgument(!dataTrees.isEmpty());
36 public static DOMActionInstance of(final SchemaPath type, final Set<DOMDataTreeIdentifier> dataTrees) {
37 return new DOMActionInstance(type, dataTrees);
40 public static DOMActionInstance of(final SchemaPath type, final DOMDataTreeIdentifier... dataTrees) {
41 return of(type, ImmutableSet.copyOf(dataTrees));
44 public static DOMActionInstance of(final SchemaPath type, final LogicalDatastoreType datastore,
45 final YangInstanceIdentifier path) {
46 return of(type, ImmutableSet.of(new DOMDataTreeIdentifier(datastore, path)));
50 * Return the set of data trees on which this action is available. These identifiers are required to point
51 * to concrete items, i.e. they may not be wildcards.
53 * @return Set of trees on which this action is available.
55 public Set<DOMDataTreeIdentifier> getDataTrees() {
60 * Return the operation type.
62 * @return operation type.
64 public SchemaPath getType() {
69 public int hashCode() {
70 return Objects.hash(getType(), dataTrees);
74 public boolean equals(final @Nullable Object obj) {
78 if (!(obj instanceof DOMActionInstance)) {
81 final DOMActionInstance other = (DOMActionInstance) obj;
82 return getType().equals(other.type) && dataTrees.equals(other.dataTrees);
86 public String toString() {
87 return MoreObjects.toStringHelper(this).add("type", type).add("dataTrees", dataTrees).toString();