2 * Copyright (c) 2015 - 2016 Ericsson India Global Services Pvt Ltd. 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.genius.utils.batching;
10 import static java.util.Objects.requireNonNull;
12 import com.google.common.util.concurrent.ListenableFuture;
13 import com.google.common.util.concurrent.SettableFuture;
14 import org.opendaylight.yangtools.concepts.Identifier;
15 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
17 public class ActionableResourceImpl implements ActionableResource {
18 private Object instance;
19 private Object oldInstance;
21 private InstanceIdentifier identifier;
23 private final SettableFuture future = SettableFuture.create();
26 public ActionableResourceImpl(String key) {
27 this.key = requireNonNull(key);
30 ActionableResourceImpl(InstanceIdentifier identifier, short action, Object updatedData, Object oldData) {
33 this.identifier = requireNonNull(identifier);
34 this.instance = updatedData;
35 this.oldInstance = oldData;
38 ActionableResourceImpl(Identifier key, InstanceIdentifier identifier, short action, Object updatedData,
40 this.key = requireNonNull(key);
42 this.identifier = requireNonNull(identifier);
43 this.instance = updatedData;
44 this.oldInstance = oldData;
48 public ActionableResourceImpl(String key, InstanceIdentifier identifier, short action, Object updatedData,
50 this.instance = updatedData;
51 this.oldInstance = oldData;
53 this.identifier = identifier;
57 public void setInstance(Object instance) {
58 this.instance = instance;
62 public Object getInstance() {
66 public void setOldInstance(Object oldInstance) {
67 this.oldInstance = oldInstance;
71 public Object getOldInstance() {
72 return this.oldInstance;
75 public void setInstanceIdentifier(InstanceIdentifier instanceIdentifier) {
76 this.identifier = instanceIdentifier;
80 public InstanceIdentifier getInstanceIdentifier() {
81 return this.identifier;
84 public void setAction(short action) {
89 public short getAction() {
93 public void setKey(String key) {
98 public ListenableFuture<Void> getResultFuture() {
103 public String toString() {
104 return key != null ? key.toString() : identifier.toString();