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-20 19:55:28 +02:00
|
|
|
PV_1_0_0_CLASSIC("1.0.0", ProtocolType.CLASSIC, ProtocolSide.BOTH),
|
2025-09-20 20:42:58 +02:00
|
|
|
PV_1_0_0_BETA("1.0.0", ProtocolType.BETA, ProtocolSide.BOTH, 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;
|
|
|
|
|
|
|
|
ProtocolVersion(String version, ProtocolType protocolType, ProtocolSide protocolSide, ProtocolVersion... compatibleVersions) {
|
|
|
|
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-19 21:27:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public final String toString() {
|
|
|
|
StringBuilder compatible = new StringBuilder("[");
|
|
|
|
for (ProtocolVersion compatibleVersion : compatibleVersions) compatible.append(compatibleVersion.buildName());
|
|
|
|
compatible.append("]");
|
|
|
|
|
2025-09-20 20:42:58 +02:00
|
|
|
return "{version=" + version + ";type=" + protocolType.toString() + ";side=" + protocolSide.toString() + ";compatible=" + compatible + "}";
|
2025-09-19 21:27:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public final String buildName() {
|
|
|
|
return version + "-" + protocolType.toString();
|
|
|
|
}
|
|
|
|
|
2025-09-20 15:17:36 +02:00
|
|
|
public enum ProtocolType implements Serializable {
|
2025-09-19 21:27:35 +02:00
|
|
|
CLASSIC, // -> See "_old" Projects on GitHub Organisation https://github.com/Open-Autonomous-Connection/
|
|
|
|
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
|
|
|
|
SERVER, // Protocol version can only used on Server
|
|
|
|
BOTH // Protocol version can only used on Server and Client
|
|
|
|
|
|
|
|
;
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public final String toString() {
|
|
|
|
return name().toUpperCase();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|