2025-09-24 22:02:10 +02:00
|
|
|
package org.openautonomousconnection.protocol.versions;
|
2025-09-19 21:27:35 +02:00
|
|
|
|
|
|
|
|
import lombok.Getter;
|
|
|
|
|
|
|
|
|
|
import java.io.Serializable;
|
2025-09-20 11:48:29 +02:00
|
|
|
import java.util.ArrayList;
|
2025-09-19 21:27:35 +02:00
|
|
|
import java.util.Arrays;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
2025-09-29 17:46:30 +02:00
|
|
|
/**
|
|
|
|
|
* Enum representing different protocol versions, their types, sides, and compatibility.
|
|
|
|
|
*/
|
2025-09-19 21:27:35 +02:00
|
|
|
public enum ProtocolVersion implements Serializable {
|
2025-09-29 17:46:30 +02:00
|
|
|
/**
|
2026-02-21 23:12:43 +01:00
|
|
|
* For classic OAC-Project => <a href="https://repo.open-autonomous-connection.org/Open-Autonomous-Connection/">"classic"-branch</a>
|
2025-09-29 17:46:30 +02:00
|
|
|
*/
|
2026-02-21 23:12:43 +01:00
|
|
|
@Deprecated(forRemoval = false, since = "1.0.1-BETA.0.1")
|
2025-12-08 09:59:58 +01:00
|
|
|
PV_1_0_0_CLASSIC("1.0.0", ProtocolType.CLASSIC, ProtocolSide.WEB_INS, List.of(Protocol.HTTP)),
|
2025-09-29 17:46:30 +02:00
|
|
|
|
|
|
|
|
/**
|
2026-02-21 23:12:43 +01:00
|
|
|
* Version {@link ProtocolVersion#PV_1_0_0_BETA} has many bugs and does not work as expected (occurred by incompleted packets).
|
|
|
|
|
* Use {@link ProtocolVersion#PV_1_0_1_BETA} or newer.
|
2025-09-29 17:46:30 +02:00
|
|
|
*/
|
2026-02-21 23:12:43 +01:00
|
|
|
@Deprecated(forRemoval = false, since = "1.0.1-BETA.0.1")
|
|
|
|
|
PV_1_0_0_BETA("1.0.0", ProtocolType.BETA, ProtocolSide.ALL, List.of(Protocol.OAC)),
|
|
|
|
|
|
|
|
|
|
PV_1_0_1_BETA("1.0.1", ProtocolType.BETA, ProtocolSide.ALL, List.of(Protocol.OAC), PV_1_0_0_BETA),
|
2026-01-18 18:17:35 +01:00
|
|
|
;
|
2025-09-19 21:27:35 +02:00
|
|
|
|
2025-09-29 17:46:30 +02:00
|
|
|
/**
|
|
|
|
|
* The version string of the protocol version.
|
|
|
|
|
*/
|
2025-09-19 21:27:35 +02:00
|
|
|
@Getter
|
|
|
|
|
private final String version;
|
2025-09-29 17:46:30 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The type of the protocol version.
|
|
|
|
|
*/
|
2025-09-19 21:27:35 +02:00
|
|
|
@Getter
|
|
|
|
|
private final ProtocolType protocolType;
|
2025-09-29 17:46:30 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The side(s) the protocol version is intended for.
|
|
|
|
|
*/
|
2025-09-19 21:27:35 +02:00
|
|
|
@Getter
|
|
|
|
|
private final ProtocolSide protocolSide;
|
2025-09-29 17:46:30 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* List of protocol versions that are compatible with this version.
|
|
|
|
|
*/
|
2025-09-19 21:27:35 +02:00
|
|
|
@Getter
|
|
|
|
|
private final List<ProtocolVersion> compatibleVersions;
|
2025-09-29 17:46:30 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* List of supported protocols.
|
|
|
|
|
*/
|
2025-09-25 23:40:24 +02:00
|
|
|
@Getter
|
|
|
|
|
private final List<Protocol> supportedProtocols;
|
2025-09-19 21:27:35 +02:00
|
|
|
|
2025-09-29 17:46:30 +02:00
|
|
|
/**
|
|
|
|
|
* Constructor for ProtocolVersion enum.
|
|
|
|
|
*
|
|
|
|
|
* @param version The version string.
|
|
|
|
|
* @param protocolType The type of the protocol.
|
|
|
|
|
* @param protocolSide The side(s) the protocol is intended for.
|
|
|
|
|
* @param supportedProtocols List of supported protocols.
|
|
|
|
|
* @param compatibleVersions Varargs of compatible protocol versions.
|
|
|
|
|
*/
|
2025-09-25 23:40:24 +02:00
|
|
|
ProtocolVersion(String version, ProtocolType protocolType, ProtocolSide protocolSide, List<Protocol> supportedProtocols, ProtocolVersion... compatibleVersions) {
|
2025-09-19 21:27:35 +02:00
|
|
|
this.version = version;
|
|
|
|
|
this.protocolType = protocolType;
|
|
|
|
|
this.protocolSide = protocolSide;
|
2025-09-20 15:17:36 +02:00
|
|
|
this.compatibleVersions = new ArrayList<>(Arrays.stream(compatibleVersions).toList());
|
|
|
|
|
if (!this.compatibleVersions.contains(this)) this.compatibleVersions.add(this);
|
2025-09-25 23:40:24 +02:00
|
|
|
this.supportedProtocols = supportedProtocols;
|
2025-09-19 21:27:35 +02:00
|
|
|
}
|
|
|
|
|
|
2025-09-29 17:46:30 +02:00
|
|
|
/**
|
|
|
|
|
* Returns a string representation of the protocol version, including its version, type, side, supported protocols, and compatible versions.
|
2025-09-29 18:46:31 +02:00
|
|
|
*
|
2025-09-29 17:46:30 +02:00
|
|
|
* @return a string representation of the protocol version.
|
|
|
|
|
*/
|
2025-09-19 21:27:35 +02:00
|
|
|
@Override
|
|
|
|
|
public final String toString() {
|
|
|
|
|
StringBuilder compatible = new StringBuilder("[");
|
2025-09-25 23:40:24 +02:00
|
|
|
StringBuilder supported = new StringBuilder("[");
|
2025-09-29 17:46:30 +02:00
|
|
|
|
2025-09-19 21:27:35 +02:00
|
|
|
for (ProtocolVersion compatibleVersion : compatibleVersions) compatible.append(compatibleVersion.buildName());
|
2025-09-25 23:40:24 +02:00
|
|
|
for (Protocol supportedProtocol : supportedProtocols) supported.append(supportedProtocol.toString());
|
2025-09-29 17:46:30 +02:00
|
|
|
|
2025-09-19 21:27:35 +02:00
|
|
|
compatible.append("]");
|
2025-09-25 23:40:24 +02:00
|
|
|
supported.append("]");
|
2025-09-19 21:27:35 +02:00
|
|
|
|
2025-09-25 23:40:24 +02:00
|
|
|
return "{version=" + version + ";type=" + protocolType.toString() + ";side=" + protocolSide.toString() + ";supportedProtocols=" + supported + ";compatibleVersions=" + compatible + "}";
|
2025-09-19 21:27:35 +02:00
|
|
|
}
|
|
|
|
|
|
2025-09-29 17:46:30 +02:00
|
|
|
/**
|
|
|
|
|
* Builds a name for the protocol version combining its version and type.
|
2025-09-29 18:46:31 +02:00
|
|
|
*
|
2025-09-29 17:46:30 +02:00
|
|
|
* @return a string representing the name of the protocol version.
|
|
|
|
|
*/
|
2025-09-19 21:27:35 +02:00
|
|
|
public final String buildName() {
|
|
|
|
|
return version + "-" + protocolType.toString();
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-29 17:46:30 +02:00
|
|
|
/**
|
|
|
|
|
* Enum representing different protocols.
|
|
|
|
|
*/
|
2025-09-25 23:40:24 +02:00
|
|
|
public enum Protocol implements Serializable {
|
|
|
|
|
HTTP,
|
|
|
|
|
HTTPS,
|
2025-09-25 23:41:17 +02:00
|
|
|
OAC;
|
2025-09-25 23:40:24 +02:00
|
|
|
|
2025-09-29 17:46:30 +02:00
|
|
|
/**
|
|
|
|
|
* Returns the name of the protocol in uppercase.
|
2025-09-29 18:46:31 +02:00
|
|
|
*
|
2025-09-29 17:46:30 +02:00
|
|
|
* @return the name of the protocol in uppercase.
|
|
|
|
|
*/
|
2025-09-25 23:40:24 +02:00
|
|
|
@Override
|
|
|
|
|
public final String toString() {
|
|
|
|
|
return name().toUpperCase();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-29 17:46:30 +02:00
|
|
|
/**
|
|
|
|
|
* Enum representing different types of protocol versions.
|
|
|
|
|
*/
|
2025-09-20 15:17:36 +02:00
|
|
|
public enum ProtocolType implements Serializable {
|
2025-09-29 17:46:30 +02:00
|
|
|
/**
|
|
|
|
|
* Classic Protocol Type, see old OAC-Project: <a href="https://repo.open-autonomous-connection.org/Open-Autonomous-Connection/">*_old</a>
|
|
|
|
|
*/
|
|
|
|
|
CLASSIC,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Beta Protocol Type, may be unstable and subject to change.
|
|
|
|
|
*/
|
2025-09-19 21:27:35 +02:00
|
|
|
BETA,
|
2025-09-29 17:46:30 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Stable Protocol Type, recommended for production use.
|
|
|
|
|
*/
|
2025-09-20 20:42:58 +02:00
|
|
|
STABLE;
|
2025-09-19 21:27:35 +02:00
|
|
|
|
2025-09-29 17:46:30 +02:00
|
|
|
/**
|
|
|
|
|
* Returns the name of the protocol in uppercase.
|
2025-09-29 18:46:31 +02:00
|
|
|
*
|
2025-09-29 17:46:30 +02:00
|
|
|
* @return the name of the protocol in uppercase.
|
|
|
|
|
*/
|
2025-09-19 21:27:35 +02:00
|
|
|
@Override
|
|
|
|
|
public final String toString() {
|
|
|
|
|
return name().toUpperCase();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-29 17:46:30 +02:00
|
|
|
/**
|
|
|
|
|
* Enum representing different sides where the protocol version can be used.
|
|
|
|
|
*/
|
2025-09-20 15:17:36 +02:00
|
|
|
public enum ProtocolSide implements Serializable {
|
2025-09-29 17:46:30 +02:00
|
|
|
/**
|
|
|
|
|
* Client Side only
|
|
|
|
|
*/
|
2025-12-08 09:59:58 +01:00
|
|
|
CLIENT,
|
2025-09-19 21:27:35 +02:00
|
|
|
|
2025-09-29 17:46:30 +02:00
|
|
|
/**
|
2025-12-08 09:59:58 +01:00
|
|
|
* INS Server Side only
|
2025-09-29 17:46:30 +02:00
|
|
|
*/
|
2025-12-08 09:59:58 +01:00
|
|
|
INS,
|
2025-09-29 17:46:30 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Web Server Side only
|
|
|
|
|
*/
|
|
|
|
|
WEB,
|
|
|
|
|
|
|
|
|
|
/**
|
2025-12-08 09:59:58 +01:00
|
|
|
* Both INS and Web Server Side
|
2025-09-29 17:46:30 +02:00
|
|
|
*/
|
2025-12-08 09:59:58 +01:00
|
|
|
WEB_INS,
|
2025-09-29 17:46:30 +02:00
|
|
|
|
|
|
|
|
/**
|
2025-12-08 09:59:58 +01:00
|
|
|
* Both Client and INS Server Side
|
2025-09-29 17:46:30 +02:00
|
|
|
*/
|
2025-12-08 09:59:58 +01:00
|
|
|
CLIENT_INS,
|
2025-09-29 17:46:30 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Both Client and Web Server Side
|
|
|
|
|
*/
|
|
|
|
|
CLIENT_WEB,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* All Sides
|
|
|
|
|
*/
|
2025-09-29 18:46:31 +02:00
|
|
|
ALL;
|
2025-09-19 21:27:35 +02:00
|
|
|
|
2025-09-29 17:46:30 +02:00
|
|
|
/**
|
|
|
|
|
* Returns the name of the protocol in uppercase.
|
2025-09-29 18:46:31 +02:00
|
|
|
*
|
2025-09-29 17:46:30 +02:00
|
|
|
* @return the name of the protocol in uppercase.
|
|
|
|
|
*/
|
2025-09-19 21:27:35 +02:00
|
|
|
@Override
|
|
|
|
|
public final String toString() {
|
|
|
|
|
return name().toUpperCase();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|