From 155f62f098abbfaa1255c39a7053ffb907f43966 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Tue, 19 Dec 2023 00:00:21 -0800 Subject: [PATCH] [wpiutil] Add serializable marker interfaces --- .../java/edu/wpi/first/util/WPISerializable.java | 8 ++++++++ .../first/util/protobuf/ProtobufSerializable.java | 15 +++++++++++++++ .../wpi/first/util/struct/StructSerializable.java | 15 +++++++++++++++ 3 files changed, 38 insertions(+) create mode 100644 wpiutil/src/main/java/edu/wpi/first/util/WPISerializable.java create mode 100644 wpiutil/src/main/java/edu/wpi/first/util/protobuf/ProtobufSerializable.java create mode 100644 wpiutil/src/main/java/edu/wpi/first/util/struct/StructSerializable.java diff --git a/wpiutil/src/main/java/edu/wpi/first/util/WPISerializable.java b/wpiutil/src/main/java/edu/wpi/first/util/WPISerializable.java new file mode 100644 index 00000000000..753f40d2078 --- /dev/null +++ b/wpiutil/src/main/java/edu/wpi/first/util/WPISerializable.java @@ -0,0 +1,8 @@ +// Copyright (c) FIRST and other WPILib contributors. +// Open Source Software; you can modify and/or share it under the terms of +// the WPILib BSD license file in the root directory of this project. + +package edu.wpi.first.util; + +/** Marker interface to indicate a class is serializable using WPI serialization methods. */ +public interface WPISerializable {} diff --git a/wpiutil/src/main/java/edu/wpi/first/util/protobuf/ProtobufSerializable.java b/wpiutil/src/main/java/edu/wpi/first/util/protobuf/ProtobufSerializable.java new file mode 100644 index 00000000000..78fdf8fbff0 --- /dev/null +++ b/wpiutil/src/main/java/edu/wpi/first/util/protobuf/ProtobufSerializable.java @@ -0,0 +1,15 @@ +// Copyright (c) FIRST and other WPILib contributors. +// Open Source Software; you can modify and/or share it under the terms of +// the WPILib BSD license file in the root directory of this project. + +package edu.wpi.first.util.protobuf; + +import edu.wpi.first.util.WPISerializable; + +/** + * Marker interface to indicate a class is serializable using Protobuf serialization. + * + *

While this cannot be enforced by the interface, any class implementing this interface should + * provide a public final static `proto` member variable. + */ +public interface ProtobufSerializable extends WPISerializable {} diff --git a/wpiutil/src/main/java/edu/wpi/first/util/struct/StructSerializable.java b/wpiutil/src/main/java/edu/wpi/first/util/struct/StructSerializable.java new file mode 100644 index 00000000000..93cf6f262b0 --- /dev/null +++ b/wpiutil/src/main/java/edu/wpi/first/util/struct/StructSerializable.java @@ -0,0 +1,15 @@ +// Copyright (c) FIRST and other WPILib contributors. +// Open Source Software; you can modify and/or share it under the terms of +// the WPILib BSD license file in the root directory of this project. + +package edu.wpi.first.util.struct; + +import edu.wpi.first.util.WPISerializable; + +/** + * Marker interface to indicate a class is serializable using Struct serialization. + * + *

While this cannot be enforced by the interface, any class implementing this interface should + * provide a public final static `struct` member variable. + */ +public interface StructSerializable extends WPISerializable {}