Class ValidatorFactory

java.lang.Object
com.example.common.validate.ValidatorFactory

public class ValidatorFactory extends Object
The ValidatorFactory class provides static methods for creating instances of various Validators.
  • Constructor Details

    • ValidatorFactory

      public ValidatorFactory()
  • Method Details

    • getRangeNumberValidation

      public static ValidatorInterface getRangeNumberValidation(String value, int min, int max)
      Creates a RangeNumberValidation Validator with the specified value, minimum, and maximum values.
      Parameters:
      value - the value to validate
      min - the minimum value of the range
      max - the maximum value of the range
      Returns:
      a RangeNumberValidation Validator
    • getIntegerNumberValidator

      public static ValidatorInterface getIntegerNumberValidator(String value)
      Creates an ValidateIntegerNumber Validator with the specified value.
      Parameters:
      value - the value to validate as an integer number
      Returns:
      an ValidateIntegerNumber Validator
    • getIpValidator

      public static ValidatorInterface getIpValidator(String value)
      Creates an IpValidator Validator with the specified value.
      Parameters:
      value - the IP address value to validate
      Returns:
      an IpValidator Validator
    • getNotUsedPortValidation

      public static ValidatorInterface getNotUsedPortValidation(String value, TransportFactory transportFactory)
      Creates a NotUsedPortsValidator Validator with the specified value and transport factory.
      Parameters:
      value - the value representing a port number to validate
      transportFactory - the TransportFactory object for creating listeners
      Returns:
      a NotUsedPortsValidator Validator
    • getPortValidation

      public static ValidatorInterface getPortValidation(String value, int minPort, int maxPort, Boolean withValidationIsUsed, TransportFactory transportFactory)
      Creates a compound PortValidation Validator with integer number, range and not used port validation.
      Parameters:
      value - the value representing a port number to validate
      minPort - the minimum port number allowed
      maxPort - the maximum port number allowed
      withValidationIsUsed - flag to indicate whether to perform not used port validation
      transportFactory - the TransportFactory object for creating listeners
      Returns:
      a validation chain of PortValidation Validator