Introduce WritableObject/WritableIdentifier
[yangtools.git] / common / concepts / src / main / java / org / opendaylight / yangtools / concepts / WritableObject.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.yangtools.concepts;
9
10 import com.google.common.annotations.Beta;
11 import java.io.DataOutput;
12 import java.io.IOException;
13 import javax.annotation.Nonnull;
14
15 /**
16  * Marker interface for an object which can be written out to an {@link DataOutput}. Classes implementing this
17  * interface should declare a corresponding
18  *
19  * <pre>
20  *      public static CLASS readFrom(DataInput in) throws IOException;
21  * </pre>
22  *
23  * The serialization format provided by this abstraction does not guarantee versioning. Callers are responsible for
24  * ensuring the source stream is correctly positioned.
25  *
26  * @author Robert Varga
27  */
28 @Beta
29 public interface WritableObject {
30     /**
31      * Serialize this object into a {@link DataOutput} as a fixed-format stream.
32      *
33      * @param out Data output
34      * @throws IOException if an I/O error occurs
35      * @throws NullPointerException if out is null
36      */
37     void writeTo(@Nonnull DataOutput out) throws IOException;
38 }