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;
|
|
|
|
|
|
|
|
public enum ProtocolVersion implements Serializable {
|
2025-09-25 23:40:24 +02:00
|
|
|
PV_1_0_0_CLASSIC("1.0.0", ProtocolType.CLASSIC, ProtocolSide.WEB_DNS, List.of(Protocol.HTTP)),
|
|
|
|
PV_1_0_0_BETA("1.0.0", ProtocolType.BETA, ProtocolSide.ALL, List.of(Protocol.OAC), PV_1_0_0_CLASSIC);
|
2025-09-19 21:27:35 +02:00
|
|
|
|
|
|
|
@Getter
|
|
|
|
private final String version;
|
|
|
|
@Getter
|
|
|
|
private final ProtocolType protocolType;
|
|
|
|
@Getter
|
|
|
|
private final ProtocolSide protocolSide;
|
|
|
|
@Getter
|
|
|
|
private final List<ProtocolVersion> compatibleVersions;
|
2025-09-25 23:40:24 +02:00
|
|
|
@Getter
|
|
|
|
private final List<Protocol> supportedProtocols;
|
2025-09-19 21:27:35 +02:00
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public final String toString() {
|
|
|
|
StringBuilder compatible = new StringBuilder("[");
|
2025-09-25 23:40:24 +02:00
|
|
|
StringBuilder supported = new StringBuilder("[");
|
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-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
|
|
|
}
|
|
|
|
|
|
|
|
public final String buildName() {
|
|
|
|
return version + "-" + protocolType.toString();
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
|
|
|
@Override
|
|
|
|
public final String toString() {
|
|
|
|
return name().toUpperCase();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2025-09-20 15:17:36 +02:00
|
|
|
public enum ProtocolType implements Serializable {
|
2025-09-25 23:40:24 +02:00
|
|
|
CLASSIC, // -> See "_old" Projects https://repo.open-autonomous-connection.org/Open-Autonomous-Connection/
|
2025-09-19 21:27:35 +02:00
|
|
|
BETA,
|
2025-09-20 20:42:58 +02:00
|
|
|
STABLE;
|
2025-09-19 21:27:35 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public final String toString() {
|
|
|
|
return name().toUpperCase();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2025-09-20 15:17:36 +02:00
|
|
|
public enum ProtocolSide implements Serializable {
|
2025-09-19 21:27:35 +02:00
|
|
|
CLIENT, // Protocol version can only used on Client
|
2025-09-25 23:40:24 +02:00
|
|
|
DNS, // Protocol version can only used on DNS Server
|
|
|
|
WEB, // Protocol version can only used on Web Server
|
|
|
|
|
|
|
|
WEB_DNS, // Protocol version can only used on DNS and WebSerber
|
|
|
|
|
|
|
|
CLIENT_DNS, // Protocol version can only used on DNS and Client
|
|
|
|
CLIENT_WEB, // Protocol version can only used on WebServer and Client
|
2025-09-19 21:27:35 +02:00
|
|
|
|
2025-09-25 23:40:24 +02:00
|
|
|
ALL // Protocol version can used on all Sides
|
2025-09-19 21:27:35 +02:00
|
|
|
;
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public final String toString() {
|
|
|
|
return name().toUpperCase();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|