- Added comments
This commit is contained in:
@@ -7,21 +7,59 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Enum representing different protocol versions, their types, sides, and compatibility.
|
||||
*/
|
||||
public enum ProtocolVersion implements Serializable {
|
||||
/**
|
||||
* Support for old OAC-Project => <a href="https://repo.open-autonomous-connection.org/Open-Autonomous-Connection/">*_old</a>
|
||||
*/
|
||||
PV_1_0_0_CLASSIC("1.0.0", ProtocolType.CLASSIC, ProtocolSide.WEB_DNS, List.of(Protocol.HTTP)),
|
||||
|
||||
/**
|
||||
* First Beta Version of OAC-Protocol
|
||||
*/
|
||||
PV_1_0_0_BETA("1.0.0", ProtocolType.BETA, ProtocolSide.ALL, List.of(Protocol.OAC), PV_1_0_0_CLASSIC);
|
||||
|
||||
/**
|
||||
* The version string of the protocol version.
|
||||
*/
|
||||
@Getter
|
||||
private final String version;
|
||||
|
||||
/**
|
||||
* The type of the protocol version.
|
||||
*/
|
||||
@Getter
|
||||
private final ProtocolType protocolType;
|
||||
|
||||
/**
|
||||
* The side(s) the protocol version is intended for.
|
||||
*/
|
||||
@Getter
|
||||
private final ProtocolSide protocolSide;
|
||||
|
||||
/**
|
||||
* List of protocol versions that are compatible with this version.
|
||||
*/
|
||||
@Getter
|
||||
private final List<ProtocolVersion> compatibleVersions;
|
||||
|
||||
/**
|
||||
* List of supported protocols.
|
||||
*/
|
||||
@Getter
|
||||
private final List<Protocol> supportedProtocols;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
ProtocolVersion(String version, ProtocolType protocolType, ProtocolSide protocolSide, List<Protocol> supportedProtocols, ProtocolVersion... compatibleVersions) {
|
||||
this.version = version;
|
||||
this.protocolType = protocolType;
|
||||
@@ -31,57 +69,123 @@ public enum ProtocolVersion implements Serializable {
|
||||
this.supportedProtocols = supportedProtocols;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of the protocol version, including its version, type, side, supported protocols, and compatible versions.
|
||||
* @return a string representation of the protocol version.
|
||||
*/
|
||||
@Override
|
||||
public final String toString() {
|
||||
StringBuilder compatible = new StringBuilder("[");
|
||||
StringBuilder supported = new StringBuilder("[");
|
||||
|
||||
for (ProtocolVersion compatibleVersion : compatibleVersions) compatible.append(compatibleVersion.buildName());
|
||||
for (Protocol supportedProtocol : supportedProtocols) supported.append(supportedProtocol.toString());
|
||||
|
||||
compatible.append("]");
|
||||
supported.append("]");
|
||||
|
||||
return "{version=" + version + ";type=" + protocolType.toString() + ";side=" + protocolSide.toString() + ";supportedProtocols=" + supported + ";compatibleVersions=" + compatible + "}";
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a name for the protocol version combining its version and type.
|
||||
* @return a string representing the name of the protocol version.
|
||||
*/
|
||||
public final String buildName() {
|
||||
return version + "-" + protocolType.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Enum representing different protocols.
|
||||
*/
|
||||
public enum Protocol implements Serializable {
|
||||
HTTP,
|
||||
HTTPS,
|
||||
OAC;
|
||||
|
||||
/**
|
||||
* Returns the name of the protocol in uppercase.
|
||||
* @return the name of the protocol in uppercase.
|
||||
*/
|
||||
@Override
|
||||
public final String toString() {
|
||||
return name().toUpperCase();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enum representing different types of protocol versions.
|
||||
*/
|
||||
public enum ProtocolType implements Serializable {
|
||||
CLASSIC, // -> See "_old" Projects https://repo.open-autonomous-connection.org/Open-Autonomous-Connection/
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
BETA,
|
||||
|
||||
/**
|
||||
* Stable Protocol Type, recommended for production use.
|
||||
*/
|
||||
STABLE;
|
||||
|
||||
/**
|
||||
* Returns the name of the protocol in uppercase.
|
||||
* @return the name of the protocol in uppercase.
|
||||
*/
|
||||
@Override
|
||||
public final String toString() {
|
||||
return name().toUpperCase();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enum representing different sides where the protocol version can be used.
|
||||
*/
|
||||
public enum ProtocolSide implements Serializable {
|
||||
/**
|
||||
* Client Side only
|
||||
*/
|
||||
CLIENT, // Protocol version can only used on Client
|
||||
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
|
||||
/**
|
||||
* DNS Server Side only
|
||||
*/
|
||||
DNS,
|
||||
|
||||
CLIENT_DNS, // Protocol version can only used on DNS and Client
|
||||
CLIENT_WEB, // Protocol version can only used on WebServer and Client
|
||||
/**
|
||||
* Web Server Side only
|
||||
*/
|
||||
WEB,
|
||||
|
||||
ALL // Protocol version can used on all Sides
|
||||
/**
|
||||
* Both DNS and Web Server Side
|
||||
*/
|
||||
WEB_DNS,
|
||||
|
||||
/**
|
||||
* Both Client and DNS Server Side
|
||||
*/
|
||||
CLIENT_DNS,
|
||||
|
||||
/**
|
||||
* Both Client and Web Server Side
|
||||
*/
|
||||
CLIENT_WEB,
|
||||
|
||||
/**
|
||||
* All Sides
|
||||
*/
|
||||
ALL
|
||||
;
|
||||
|
||||
/**
|
||||
* Returns the name of the protocol in uppercase.
|
||||
* @return the name of the protocol in uppercase.
|
||||
*/
|
||||
@Override
|
||||
public final String toString() {
|
||||
return name().toUpperCase();
|
||||
|
||||
Reference in New Issue
Block a user