5f081c77cd50686e3c3f48109654440cc5425d5a
[controller.git] / opendaylight / md-sal / cds-access-api / src / main / java / org / opendaylight / controller / cluster / access / commands / ExistsTransactionSuccess.java
1 /*
2  * Copyright (c) 2016 Cisco Systems, Inc. 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.controller.cluster.access.commands;
9
10 import com.google.common.annotations.Beta;
11 import com.google.common.base.MoreObjects.ToStringHelper;
12 import org.opendaylight.controller.cluster.access.ABIVersion;
13 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
14
15 /**
16  * Successuful reply to an {@link ExistsTransactionRequest}. It indicates presence of requested data via
17  * {@link #getExists()}.
18  *
19  * @author Robert Varga
20  */
21 @Beta
22 public final class ExistsTransactionSuccess extends TransactionSuccess<ExistsTransactionSuccess> {
23     private static final long serialVersionUID = 1L;
24     private final boolean exists;
25
26     public ExistsTransactionSuccess(final TransactionIdentifier target, final long sequence, final boolean exists) {
27         this(target, sequence, 0, exists);
28     }
29
30     ExistsTransactionSuccess(final TransactionIdentifier target, final long sequence, final long retry,
31             final boolean exists) {
32         super(target, sequence, retry);
33         this.exists = exists;
34     }
35
36     public boolean getExists() {
37         return exists;
38     }
39
40     @Override
41     protected ExistsTransactionSuccessProxyV1 externalizableProxy(final ABIVersion version) {
42         return new ExistsTransactionSuccessProxyV1(this);
43     }
44
45     @Override
46     protected ExistsTransactionSuccess cloneAsVersion(final ABIVersion version) {
47         return this;
48     }
49
50     @Override
51     protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
52         return super.addToStringAttributes(toStringHelper).add("exists", exists);
53     }
54 }