Turn ActionableResource into an abstract class
[genius.git] / mdsalutil / mdsalutil-api / src / main / java / org / opendaylight / genius / utils / batching / ActionableResource.java
1 /*
2  * Copyright (c) 2015 - 2016 Ericsson India Global Services Pvt Ltd. 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.genius.utils.batching;
9
10 import static java.util.Objects.requireNonNull;
11
12 import com.google.common.util.concurrent.ListenableFuture;
13 import org.eclipse.jdt.annotation.NonNull;
14 import org.opendaylight.yangtools.yang.binding.DataObject;
15 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
16
17 public abstract class ActionableResource<T extends DataObject> {
18
19     static final short CREATE = 1;
20     static final short UPDATE = 2;
21     static final short DELETE = 3;
22     static final short READ = 4;
23     // MDSAL-534 Merge,Put with no create_missing_parents flag
24     static final short UPDATECONTAINER = 5;
25
26     private final InstanceIdentifier<T> path;
27     private final short action;
28
29     // Hidden to prevent subclassing outside of this package
30     ActionableResource(final InstanceIdentifier<T> path, final short action) {
31         this.path = requireNonNull(path);
32         this.action = action;
33     }
34
35     final short getAction() {
36         return action;
37     }
38
39     final @NonNull InstanceIdentifier<T> getInstanceIdentifier() {
40         return path;
41     }
42
43     abstract Object getInstance();
44
45     abstract Object getOldInstance();
46
47     abstract ListenableFuture<Void> getResultFuture();
48 }