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.concepts;
10 import com.google.common.base.MoreObjects;
11 import com.google.common.base.Preconditions;
12 import java.io.Serializable;
13 import org.opendaylight.yangtools.concepts.Immutable;
15 public abstract class Envelope<T extends Message<?, ?>> implements Immutable, Serializable {
16 private static final long serialVersionUID = 1L;
18 private final T message;
19 private final long txSequence;
20 private final long sessionId;
22 Envelope(final T message, final long sessionId, final long txSequence) {
23 this.message = Preconditions.checkNotNull(message);
24 this.sessionId = sessionId;
25 this.txSequence = txSequence;
29 * Get the enclosed message.
31 * @return enclose message
33 public T getMessage() {
38 * Get the message transmission sequence of this envelope.
40 * @return Message sequence
42 public long getTxSequence() {
47 * Get the session identifier.
49 * @return Session identifier
51 public long getSessionId() {
56 public String toString() {
57 return MoreObjects.toStringHelper(Envelope.class).add("sessionId", Long.toHexString(sessionId))
58 .add("txSequence", Long.toHexString(txSequence)).add("message", message).toString();
61 final Object writeReplace() {
65 abstract AbstractEnvelopeProxy<T> createProxy();