Class URLGenerator

java.lang.Object
org.instancio.internal.generator.AbstractGenerator<T>
org.instancio.internal.generator.net.URLGenerator
All Implemented Interfaces:
AsStringGeneratorSpec<URL>, Generator<URL>, GeneratorSpec<URL>, URLGeneratorSpec

public class URLGenerator extends AbstractGenerator<T> implements URLGeneratorSpec
  • Constructor Details

  • Method Details

    • apiMethod

      public String apiMethod()
      Description copied from class: AbstractGenerator
      Returns the public API method name of the generator spec. The returned name is used for reporting validation errors.
      Specified by:
      apiMethod in class AbstractGenerator<URL>
      Returns:
      spec name if defined, or null otherwise
    • protocol

      public URLGeneratorSpec protocol(String... protocols)
      Description copied from interface: URLGeneratorSpec
      Generate a random protocol from the given choices. If not specified, the default is HTTP.
      Specified by:
      protocol in interface URLGeneratorSpec
      Parameters:
      protocols - one or more values from which a random protocol will be selected
      Returns:
      spec builder
    • port

      public URLGeneratorSpec port(int port)
      Description copied from interface: URLGeneratorSpec
      Specifies the port number. If not specified, default port -1 will be used.
      Specified by:
      port in interface URLGeneratorSpec
      Parameters:
      port - port number to use
      Returns:
      spec builder
    • randomPort

      public URLGeneratorSpec randomPort()
      Description copied from interface: URLGeneratorSpec
      Specifies that a random port number between 1 and 65535 (inclusive) should be generated.
      Specified by:
      randomPort in interface URLGeneratorSpec
      Returns:
      spec builder
    • host

      public URLGeneratorSpec host(Generator<String> hostGenerator)
      Description copied from interface: URLGeneratorSpec
      Specifies a generator for the host name. If not specified, a random host name will be generated.
      Specified by:
      host in interface URLGeneratorSpec
      Parameters:
      hostGenerator - generator for the host name
      Returns:
      spec builder
    • file

      public URLGeneratorSpec file(Generator<String> fileGenerator)
      Description copied from interface: URLGeneratorSpec
      Specifies a generator for the file name. If not specified, blank file name will be used.
      Specified by:
      file in interface URLGeneratorSpec
      Parameters:
      fileGenerator - generator for the file
      Returns:
      spec builder
    • generate

      public URL generate(Random random)
      Description copied from interface: Generator
      Returns a generated value.

      If this method produces random data, the data needs to be generated using the provided Random instance. This ensures generated values are reproducible for a given seed value.

      Specified by:
      generate in interface Generator<URL>
      Parameters:
      random - provider for generating random values
      Returns:
      generated value or null if value is nullable, could not be generated, or generation is delegated to the engine