Reformatted code using IntelliJ

This commit is contained in:
2025-09-29 18:46:31 +02:00
parent f9ec00add4
commit facac103e7
30 changed files with 298 additions and 153 deletions

View File

@@ -24,7 +24,6 @@ import org.openautonomousconnection.protocol.versions.v1_0_0.classic.utils.Class
import java.io.File;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
/**
* The main bridge class for the protocol connection.
@@ -97,10 +96,11 @@ public final class ProtocolBridge {
/**
* Initialize the ProtocolBridge instance for the DNS server side
*
* @param protocolDNSServer The ProtocolDNSServer instance
* @param protocolSettings The ProtocolSettings instance
* @param protocolVersion The ProtocolVersion instance
* @param logFolder The folder to store the log files
* @param protocolSettings The ProtocolSettings instance
* @param protocolVersion The ProtocolVersion instance
* @param logFolder The folder to store the log files
* @throws Exception if an error occurs while initializing the ProtocolBridge
*/
@ProtocolInfo(protocolSide = ProtocolVersion.ProtocolSide.DNS)
@@ -124,10 +124,11 @@ public final class ProtocolBridge {
/**
* Initialize the ProtocolBridge instance for the web server side
*
* @param protocolWebServer The ProtocolWebServer instance
* @param protocolSettings The ProtocolSettings instance
* @param protocolVersion The ProtocolVersion instance
* @param logFolder The folder to store the log files
* @param protocolSettings The ProtocolSettings instance
* @param protocolVersion The ProtocolVersion instance
* @param logFolder The folder to store the log files
* @throws Exception if an error occurs while initializing the ProtocolBridge
*/
@ProtocolInfo(protocolSide = ProtocolVersion.ProtocolSide.WEB)
@@ -151,10 +152,11 @@ public final class ProtocolBridge {
/**
* Initialize the ProtocolBridge instance for the client side
* @param protocolClient The ProtocolClient instance
*
* @param protocolClient The ProtocolClient instance
* @param protocolSettings The ProtocolSettings instance
* @param protocolVersion The ProtocolVersion instance
* @param logFolder The folder to store the log files
* @param protocolVersion The ProtocolVersion instance
* @param logFolder The folder to store the log files
* @throws Exception if an error occurs while initializing the ProtocolBridge
*/
@ProtocolInfo(protocolSide = ProtocolVersion.ProtocolSide.CLIENT)
@@ -196,13 +198,17 @@ public final class ProtocolBridge {
GetDestinationPacket v100bGetDestinationPacket = new GetDestinationPacket();
if (isPacketSupported(v100bAuthPath)) protocolSettings.packetHandler.registerPacket(v100bAuthPath);
if (isPacketSupported(v100bUnsupportedClassicPacket)) protocolSettings.packetHandler.registerPacket(v100bUnsupportedClassicPacket);
if (isPacketSupported(v100bValidateDomainPacket)) protocolSettings.packetHandler.registerPacket(v100bValidateDomainPacket);
if (isPacketSupported(v100bGetDestinationPacket)) protocolSettings.packetHandler.registerPacket(v100bGetDestinationPacket);
if (isPacketSupported(v100bUnsupportedClassicPacket))
protocolSettings.packetHandler.registerPacket(v100bUnsupportedClassicPacket);
if (isPacketSupported(v100bValidateDomainPacket))
protocolSettings.packetHandler.registerPacket(v100bValidateDomainPacket);
if (isPacketSupported(v100bGetDestinationPacket))
protocolSettings.packetHandler.registerPacket(v100bGetDestinationPacket);
}
/**
* Register the appropriate listeners based on the current side
*
* @throws Exception if an error occurs while registering the listeners
*/
private void registerListeners() throws Exception {
@@ -234,6 +240,7 @@ public final class ProtocolBridge {
/**
* Initialize the logger instance
*
* @param logFolder The folder to store the log files
*/
private void initializeLogger(File logFolder) {
@@ -268,9 +275,10 @@ public final class ProtocolBridge {
/**
* Check if the classic protocol is supported by the current protocol version
*
* @return true if the classic protocol is supported, false otherwise
*/
public final boolean isClassicSupported() {
public boolean isClassicSupported() {
boolean yes = false;
for (ProtocolVersion compatibleVersion : protocolVersion.getCompatibleVersions()) {
// Check if the compatible version is classic
@@ -284,10 +292,11 @@ public final class ProtocolBridge {
/**
* Check if the target protocol is supported by the current protocol version
*
* @param protocol The target protocol to check
* @return true If the target protocol is supported, false otherwise
*/
public final boolean isProtocolSupported(ProtocolVersion.Protocol protocol) {
public boolean isProtocolSupported(ProtocolVersion.Protocol protocol) {
boolean yes = false;
for (ProtocolVersion compatibleVersion : protocolVersion.getCompatibleVersions()) {
// Check if the compatible version supports the target protocol
@@ -301,25 +310,28 @@ public final class ProtocolBridge {
/**
* Check if the target packet is supported by the current protocol version
*
* @param packet The target packet to check
* @return true if the target packet is supported, false otherwise
*/
public final boolean isPacketSupported(OACPacket packet) {
public boolean isPacketSupported(OACPacket packet) {
return isVersionSupported(packet.getProtocolVersion());
}
/**
* Check if the target protocol version is supported by the current protocol version
*
* @param targetVersion The target protocol version to check
* @return true if the target protocol version is supported, false otherwise
*/
public final boolean isVersionSupported(ProtocolVersion targetVersion) {
public boolean isVersionSupported(ProtocolVersion targetVersion) {
// Check if the target protocol version is the same as the current protocol version or if it is in the list of compatible versions
return protocolVersion == targetVersion || protocolVersion.getCompatibleVersions().contains(targetVersion);
}
/**
* Validate if the protocol version is valid for the current side
*
* @return true if the protocol version is valid for the current side, false otherwise
*/
private boolean validateProtocolSide() {
@@ -342,25 +354,28 @@ public final class ProtocolBridge {
/**
* Check if the current instance is running as a DNS server
*
* @return true if the current instance is running as a DNS server, false otherwise
*/
public final boolean isRunningAsDNSServer() {
public boolean isRunningAsDNSServer() {
return protocolDNSServer != null;
}
/**
* Check if the current instance is running as a client
*
* @return true if the current instance is running as a client, false otherwise
*/
public final boolean isRunningAsClient() {
public boolean isRunningAsClient() {
return protocolClient != null;
}
/**
* Check if the current instance is running as a web server
*
* @return true if the current instance is running as a web server, false otherwise
*/
public final boolean isRunningAsWebServer() {
public boolean isRunningAsWebServer() {
return protocolWebServer != null;
}
}