2 * Copyright (c) 2014 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
9 package org.opendaylight.controller.cluster.datastore.messages;
11 import org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages;
13 public class CanCommitTransactionReply implements SerializableMessage {
14 public static final Class<ThreePhaseCommitCohortMessages.CanCommitTransactionReply> SERIALIZABLE_CLASS =
15 ThreePhaseCommitCohortMessages.CanCommitTransactionReply.class;
17 public static final CanCommitTransactionReply YES = new CanCommitTransactionReply(true);
18 public static final CanCommitTransactionReply NO = new CanCommitTransactionReply(false);
20 private static final ThreePhaseCommitCohortMessages.CanCommitTransactionReply YES_SERIALIZED =
21 ThreePhaseCommitCohortMessages.CanCommitTransactionReply.newBuilder().setCanCommit(true).build();
23 private static final ThreePhaseCommitCohortMessages.CanCommitTransactionReply NO_SERIALIZED =
24 ThreePhaseCommitCohortMessages.CanCommitTransactionReply.newBuilder().setCanCommit(false).build();
26 private final boolean canCommit;
28 private CanCommitTransactionReply(final boolean canCommit) {
29 this.canCommit = canCommit;
32 public boolean getCanCommit() {
37 public Object toSerializable() {
38 return canCommit ? YES_SERIALIZED : NO_SERIALIZED;
41 public static CanCommitTransactionReply fromSerializable(final Object message) {
42 ThreePhaseCommitCohortMessages.CanCommitTransactionReply serialized =
43 (ThreePhaseCommitCohortMessages.CanCommitTransactionReply) message;
44 return serialized.getCanCommit() ? YES : NO;