Class URIGenerator

java.lang.Object
org.instancio.internal.generator.AbstractGenerator<T>
org.instancio.internal.generator.net.URIGenerator
All Implemented Interfaces:
AsStringGeneratorSpec<URI>, Generator<URI>, GeneratorSpec<URI>, URIGeneratorSpec

public class URIGenerator extends AbstractGenerator<T> implements URIGeneratorSpec
  • 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<URI>
      Returns:
      spec name if defined, or null otherwise
    • scheme

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

      public URIGeneratorSpec userInfo(String userInfo)
      Description copied from interface: URIGeneratorSpec
      Specifies username. If not specified, a null user will be generated.
      Specified by:
      userInfo in interface URIGeneratorSpec
      Parameters:
      userInfo - username to generate
      Returns:
      spec builder
    • host

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

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

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

      public URIGeneratorSpec path(Generator<String> path)
      Description copied from interface: URIGeneratorSpec
      Specifies a generator for the path. If not specified, null path will be generated.
      Specified by:
      path in interface URIGeneratorSpec
      Parameters:
      path - generator for the path
      Returns:
      spec builder
    • query

      public URIGeneratorSpec query(Generator<String> queryGenerator)
      Description copied from interface: URIGeneratorSpec
      Specifies a generator for the query. If not specified, null query will be generated.
      Specified by:
      query in interface URIGeneratorSpec
      Parameters:
      queryGenerator - generator for the query
      Returns:
      spec builder
    • fragment

      public URIGeneratorSpec fragment(Generator<String> fragmentGenerator)
      Description copied from interface: URIGeneratorSpec
      Specifies a generator for the fragmentGenerator. If not specified, null fragmentGenerator will be generated.
      Specified by:
      fragment in interface URIGeneratorSpec
      Parameters:
      fragmentGenerator - generator for the fragment
      Returns:
      spec builder
    • generate

      public URI 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<URI>
      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