Class ServiceEnvironmentType.Builder

java.lang.Object
eu.cloudnetservice.driver.service.ServiceEnvironmentType.Builder
Enclosing class:
ServiceEnvironmentType

public static class ServiceEnvironmentType.Builder extends Object
A builder for a service environment type.
Since:
4.0
  • Field Details

    • name

      private String name
    • defaultServiceStartPort

      private int defaultServiceStartPort
    • properties

      private Document properties
    • defaultProcessArguments

      private Set<String> defaultProcessArguments
  • Constructor Details

    • Builder

      public Builder()
  • Method Details

    • name

      Sets the name of the service environment type.
      Parameters:
      name - the name of the environment type.
      Returns:
      the same instance as used to call the method, for chaining.
      Throws:
      NullPointerException - if the given name is null.
    • defaultServiceStartPort

      @NonNull public @NonNull ServiceEnvironmentType.Builder defaultServiceStartPort(int defaultServiceStartPort)
      Sets the default start port to use for the service environment type if no other port was explicitly defined when creating a service which uses the service environment type. If the given port is already in use it will be counted up until a free port was found.
      Parameters:
      defaultServiceStartPort - the default start port of the service environment type.
      Returns:
      the same instance as used to call the method, for chaining.
    • properties

      Sets the properties of the service environment type. These should at least contain an identifier which type of software is wrapped by the environment type (pe or java edition service).
      Parameters:
      properties - the properties to use for the environment.
      Returns:
      the same instance as used to call the method for chaining.
      Throws:
      NullPointerException - if the given properties document is null.
    • defaultProcessArguments

      @NonNull public @NonNull ServiceEnvironmentType.Builder defaultProcessArguments(@NonNull @NonNull Collection<String> defaultProcessArguments)
      Sets the default process arguments which should get appended to the command line of all services created using the service environment type.

      This method will override all previously added process arguments. The collection will be copied into this builder, meaning that changes made to the given collection after the method call will not reflect into the builder and vice-versa.

      Parameters:
      defaultProcessArguments - the default process arguments to apply to a service command line.
      Returns:
      the same instance as used to call the method, for chaining.
      Throws:
      NullPointerException - if the given argument collection is null.
    • modifyDefaultProcessArguments

      @NonNull public @NonNull ServiceEnvironmentType.Builder modifyDefaultProcessArguments(@NonNull @NonNull Consumer<Collection<String>> modifier)
      Modifies the default process arguments which should get appended to the command line of all services created using the service environment type.
      Parameters:
      modifier - the modifier to be applied to the already added default process arguments of this builder.
      Returns:
      the same instance as used to call the method, for chaining.
      Throws:
      NullPointerException - if the given argument collection is null.
    • build

      Builds a service environment type instance based on the properties supplied to this builder.
      Returns:
      a new service environment type.
      Throws:
      NullPointerException - if no name was given.
      IllegalArgumentException - if the given default port is out of range.