Introduce WritableObject/WritableIdentifier
[yangtools.git] / common / concepts / src / main / java / org / opendaylight / yangtools / concepts / WritableObject.java
diff --git a/common/concepts/src/main/java/org/opendaylight/yangtools/concepts/WritableObject.java b/common/concepts/src/main/java/org/opendaylight/yangtools/concepts/WritableObject.java
new file mode 100644 (file)
index 0000000..7d5a3d8
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.concepts;
+
+import com.google.common.annotations.Beta;
+import java.io.DataOutput;
+import java.io.IOException;
+import javax.annotation.Nonnull;
+
+/**
+ * Marker interface for an object which can be written out to an {@link DataOutput}. Classes implementing this
+ * interface should declare a corresponding
+ *
+ * <pre>
+ *      public static CLASS readFrom(DataInput in) throws IOException;
+ * </pre>
+ *
+ * The serialization format provided by this abstraction does not guarantee versioning. Callers are responsible for
+ * ensuring the source stream is correctly positioned.
+ *
+ * @author Robert Varga
+ */
+@Beta
+public interface WritableObject {
+    /**
+     * Serialize this object into a {@link DataOutput} as a fixed-format stream.
+     *
+     * @param out Data output
+     * @throws IOException if an I/O error occurs
+     * @throws NullPointerException if out is null
+     */
+    void writeTo(@Nonnull DataOutput out) throws IOException;
+}