/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package io.airlift.testing.mysql;

import io.airlift.units.Duration;

import static java.util.Objects.requireNonNull;
import static java.util.concurrent.TimeUnit.SECONDS;

public class MySqlOptions
{
    private final Duration startupWait;
    private final Duration shutdownWait;
    private final Duration commandTimeout;

    private MySqlOptions(Duration startupWait, Duration shutdownWait, Duration commandTimeout)
    {
        this.startupWait = requireNonNull(startupWait, "startupWait is null");
        this.shutdownWait = requireNonNull(shutdownWait, "shutdownWait is null");
        this.commandTimeout = requireNonNull(commandTimeout, "commandTimeout is null");
    }

    public Duration getStartupWait()
    {
        return startupWait;
    }

    public Duration getShutdownWait()
    {
        return shutdownWait;
    }

    public Duration getCommandTimeout()
    {
        return commandTimeout;
    }

    public static Builder builder()
    {
        return new Builder();
    }

    public static class Builder
    {
        private Duration startupWait = new Duration(10, SECONDS);
        private Duration shutdownWait = new Duration(10, SECONDS);
        private Duration commandTimeout = new Duration(30, SECONDS);

        public void setStartupWait(Duration startupWait)
        {
            this.startupWait = requireNonNull(startupWait, "startupWait is null");
        }

        public void setShutdownWait(Duration shutdownWait)
        {
            this.shutdownWait = requireNonNull(shutdownWait, "shutdownWait is null");
        }

        public void setCommandTimeout(Duration commandTimeout)
        {
            this.commandTimeout = requireNonNull(commandTimeout, "commandTimeout is null");
        }

        public MySqlOptions build()
        {
            return new MySqlOptions(startupWait, shutdownWait, commandTimeout);
        }
    }
}

@@ -1810,28 +1810,31 @@
      public 
-void
+Builder
  setStartupW
@@ -1944,32 +1944,57 @@
 Wait is null%22);%0A
+            return this;%0A
         %7D%0A%0A     
@@ -1999,28 +1999,31 @@
      public 
-void
+Builder
  setShutdown
@@ -2138,32 +2138,57 @@
 Wait is null%22);%0A
+            return this;%0A
         %7D%0A%0A     
@@ -2201,12 +2201,15 @@
 lic 
-void
+Builder
  set
@@ -2342,32 +2342,57 @@
 eout is null%22);%0A
+            return this;%0A
         %7D%0A%0A     

Allow setters to be chained in MySqlOptions.Builder