// Copyright (c) 2020 UWB & LESP.
// The UWB & LESP license this file to you under the MIT license.

package cz.senslog.connector.app.config;


import cz.senslog.connector.app.config.api.DatabaseBuilder;
import cz.senslog.connector.app.config.api.DatabaseConfigurationService;

/**
 * The class {@code DatabaseBuilderImpl} represents an implementation of {@link DatabaseBuilder}.
 *
 * @author Lukas Cerny
 * @version 1.0
 * @since 1.0
 */
public class DatabaseBuilderImpl implements DatabaseBuilder {

    /** Connection url to a database. */
    private String connectionUrl;

    /** Username to a database. */
    private String username;

    /** Password to a database. */
    private String password;

    /** Name of connector in database. */
    private String connectorName;

    @Override
    public DatabaseBuilder connectionUrl(String connectionUrl) {
        this.connectionUrl = connectionUrl;
        return this;
    }

    @Override
    public DatabaseBuilder username(String username) {
        this.username = username;
        return this;
    }

    @Override
    public DatabaseBuilder password(String password) {
        this.password = password;
        return this;
    }

    @Override
    public DatabaseBuilder connectorName(String connectorName) {
        this.connectorName = connectorName;
        return this;
    }

    @Override
    public DatabaseConfigurationService build() {
        return new DatabaseConfigurationServiceImpl(connectionUrl, username, password, connectorName);
    }
}
