package com.atlassian.stash.internal.jdbc;

import com.atlassian.stash.internal.db.DbType;
import org.apache.commons.lang3.StringUtils;

import javax.annotation.Nonnull;
import java.util.Properties;

/**
 * Provides access to the driver class name, credentials and URL which are used to connect the {@code DataSource} to
 * the database.
 *
 * @see MutableDataSourceConfiguration
 */
public interface DataSourceConfiguration {

    @Nonnull
    String getDriverClassName();

    @Nonnull
    String getPassword();

    @Nonnull
    default Properties getProperties() {
        return new Properties();
    }

    @Nonnull
    String getUrl();

    @Nonnull
    String getUser();

    default boolean isInternal() {
        return DbType.isInternal(getDriverClassName());
    }

    default boolean isPasswordSet() {
        return StringUtils.isNotEmpty(getPassword());
    }
}
