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

com.scalar.db.sql.statement.builder.AlterUserStatementBuilder 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.AlterUserStatement;
import javax.annotation.Nullable;

public class AlterUserStatementBuilder {

  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 AlterUserStatement object.
     *
     * @return a AlterUserStatement object
     */
    public AlterUserStatement build() {
      return AlterUserStatement.create(username, password, userOptions);
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy