Package com.example.common.validate
Class NotUsedPortsValidator
java.lang.Object
com.example.common.validate.BaseValidator
com.example.common.validate.NotUsedPortsValidator
- All Implemented Interfaces:
ValidatorInterface
The NotUsedPortsValidator class extends the BaseValidator class and implements the ValidatorInterface.
It validates if a port is not already in use by creating a transport listener.
-
Field Summary
Fields inherited from class com.example.common.validate.BaseValidator
value
-
Constructor Summary
ConstructorsConstructorDescriptionNotUsedPortsValidator
(String value, TransportFactory transportFactory) Constructs a NotUsedPortsValidator with the specified value and transport factory. -
Method Summary
Modifier and TypeMethodDescriptionboolean
validate()
Validates if the specified port is not already in use by creating a transport listener on that port.
-
Constructor Details
-
NotUsedPortsValidator
Constructs a NotUsedPortsValidator with the specified value and transport factory.- Parameters:
value
- the value representing a port number to validatetransportFactory
- the TransportFactory object for creating listeners
-
-
Method Details
-
validate
public boolean validate()Validates if the specified port is not already in use by creating a transport listener on that port.- Specified by:
validate
in interfaceValidatorInterface
- Returns:
- true if the port is available, false if the port is already in use
-