Remove unused exceptions
[controller.git] / opendaylight / md-sal / sal-akka-raft / src / main / java / org / opendaylight / controller / cluster / raft / base / messages / EmptyExternalizableProxy.java
1 /*
2  * Copyright (c) 2017 Inocybe Technologies 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.raft.base.messages;
9
10 import com.google.common.base.Preconditions;
11 import java.io.Externalizable;
12 import java.io.ObjectInput;
13 import java.io.ObjectOutput;
14
15 /**
16  * Abstract base that implements Externalizable with no-op methods that is intended for classes that use the
17  * externalizable proxy pattern but have no data to serialize and read-resolve to a static instance.
18  *
19  * @author Thomas Pantelis
20  */
21 public abstract class EmptyExternalizableProxy implements Externalizable {
22     private static final long serialVersionUID = 1L;
23
24     private final Object readResolveTo;
25
26     protected EmptyExternalizableProxy(Object readResolveTo) {
27         this.readResolveTo = Preconditions.checkNotNull(readResolveTo);
28     }
29
30     @Override
31     public void writeExternal(ObjectOutput out) {
32     }
33
34     @Override
35     public void readExternal(ObjectInput in) {
36     }
37
38     protected Object readResolve() {
39         return readResolveTo;
40     }
41 }