2 * Copyright (c) 2016 Cisco Systems, Inc. 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.controller.cluster.access.commands;
10 import com.google.common.base.MoreObjects.ToStringHelper;
11 import java.io.IOException;
12 import java.io.ObjectInput;
13 import java.io.ObjectOutput;
14 import org.opendaylight.controller.cluster.access.ABIVersion;
15 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
18 * Successful reply to an {@link ExistsTransactionRequest}. It indicates presence of requested data via
19 * {@link #getExists()}.
21 public final class ExistsTransactionSuccess extends TransactionSuccess<ExistsTransactionSuccess> {
22 interface SerialForm extends TransactionSuccess.SerialForm<ExistsTransactionSuccess> {
24 default ExistsTransactionSuccess readExternal(final ObjectInput in, final TransactionIdentifier target,
25 final long sequence) throws IOException {
26 return new ExistsTransactionSuccess(target, sequence, in.readBoolean());
30 default void writeExternal(final ObjectOutput out, final ExistsTransactionSuccess msg) throws IOException {
31 out.writeBoolean(msg.getExists());
36 private static final long serialVersionUID = 1L;
38 private final boolean exists;
40 private ExistsTransactionSuccess(final ExistsTransactionSuccess success, final ABIVersion version) {
41 super(success, version);
42 exists = success.exists;
45 public ExistsTransactionSuccess(final TransactionIdentifier target, final long sequence, final boolean exists) {
46 super(target, sequence);
50 public boolean getExists() {
55 protected SerialForm externalizableProxy(final ABIVersion version) {
56 return ABIVersion.MAGNESIUM.lt(version) ? new ETS(this) : new ExistsTransactionSuccessProxyV1(this);
60 protected ExistsTransactionSuccess cloneAsVersion(final ABIVersion version) {
61 return new ExistsTransactionSuccess(this, version);
65 protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
66 return super.addToStringAttributes(toStringHelper).add("exists", exists);