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 class ActionableResourceImpl implements ActionableResource {
18 private final Object instance;
19 private final Object oldInstance;
20 private final Object key;
21 private final InstanceIdentifier identifier;
22 private final short action;
23 private final SettableFuture future = SettableFuture.create();
25 ActionableResourceImpl(InstanceIdentifier identifier, short action, Object updatedData, Object oldData) {
28 this.identifier = requireNonNull(identifier);
29 this.instance = updatedData;
30 this.oldInstance = oldData;
33 ActionableResourceImpl(Identifier key, InstanceIdentifier identifier, short action, Object updatedData,
35 this.key = requireNonNull(key);
37 this.identifier = requireNonNull(identifier);
38 this.instance = updatedData;
39 this.oldInstance = oldData;
43 public Object getInstance() {
48 public Object getOldInstance() {
49 return this.oldInstance;
53 public InstanceIdentifier getInstanceIdentifier() {
54 return this.identifier;
58 public short getAction() {
63 public ListenableFuture<Void> getResultFuture() {
68 public String toString() {
69 return key != null ? key.toString() : identifier.toString();