*/
package org.opendaylight.mdsal.common.api;
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+import org.eclipse.jdt.annotation.NonNull;
+import org.opendaylight.yangtools.concepts.WritableObject;
+
/**
* The concept of a logical data store, similar to RFC8342.
*/
// FIXME: 3.0.0: turn this into an interface so it can be externally-defined?
// FIXME: 3.0.0: note that mount points can have different types and policies, which can potentially be mapped
-public enum LogicalDatastoreType {
+public enum LogicalDatastoreType implements WritableObject {
/**
* Logical datastore representing operational state of the system and it's components. This datastore is used
* to describe operational state of the system and it's operation related data.
* </li>
* </ul>
*/
- OPERATIONAL,
+ OPERATIONAL(1),
/**
* Logical Datastore representing configuration state of the system and it's components. This datastore is used
* to describe intended state of the system and intended operation mode.
* </li>
* </ul>
*/
- CONFIGURATION
+ CONFIGURATION(2);
+
+ private int serialized;
+
+ LogicalDatastoreType(final int serialized) {
+ this.serialized = serialized;
+ }
+
+ @Override
+ public void writeTo(final DataOutput out) throws IOException {
+ out.writeByte(serialized);
+ }
+
+ public static @NonNull LogicalDatastoreType readFrom(final DataInput in) throws IOException {
+ final byte serialized = in.readByte();
+ switch (serialized) {
+ case 1:
+ return OPERATIONAL;
+ case 2:
+ return CONFIGURATION;
+ default:
+ throw new IOException("Unknown type " + serialized);
+ }
+ }
}