All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.scalar.db.sql.statement.builder.CreateUserStatementBuilder Maven / Gradle / Ivy

There is a newer version: 3.14.0
Show newest version
package com.scalar.db.sql.statement.builder;

import com.google.common.collect.ImmutableList;
import com.scalar.db.sql.UserOption;
import com.scalar.db.sql.statement.CreateUserStatement;
import javax.annotation.Nullable;

public class CreateUserStatementBuilder {

  public static class Start extends Buildable {
    Start(String username) {
      super(username, null, ImmutableList.of());
    }

    /**
     * Sets the password and user options.
     *
     * @param password the password
     * @param userOptions the user options
     * @return a builder object
     */
    public Buildable with(@Nullable String password, UserOption... userOptions) {
      return new Buildable(username, password, ImmutableList.copyOf(userOptions));
    }

    /**
     * Sets the user options.
     *
     * @param userOptions the user options
     * @return a builder object
     */
    public Buildable with(UserOption... userOptions) {
      return new Buildable(username, null, ImmutableList.copyOf(userOptions));
    }
  }

  public static class Buildable {
    protected final String username;
    @Nullable private final String password;
    private final ImmutableList userOptions;

    private Buildable(
        String username, @Nullable String password, ImmutableList userOptions) {
      this.username = username;
      this.password = password;
      this.userOptions = userOptions;
    }

    /**
     * Builds a CreateUserStatement object.
     *
     * @return a CreateUserStatement object
     */
    public CreateUserStatement build() {
      return CreateUserStatement.create(username, password, userOptions);
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy