5481d0de40ff45bf26f2527af2249ba46222fee6
[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  * Successful 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 boolean exists) {
27         super(target);
28         this.exists = exists;
29     }
30
31     public boolean getExists() {
32         return exists;
33     }
34
35     @Override
36     protected ExistsTransactionSuccessProxyV1 externalizableProxy(final ABIVersion version) {
37         return new ExistsTransactionSuccessProxyV1(this);
38     }
39
40     @Override
41     protected ExistsTransactionSuccess cloneAsVersion(final ABIVersion version) {
42         return this;
43     }
44
45     @Override
46     protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
47         return super.addToStringAttributes(toStringHelper).add("exists", exists);
48     }
49 }