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

com.lordofthejars.nosqlunit.cassandra.EmbeddedCassandraConfigurationBuilder Maven / Gradle / Ivy

package com.lordofthejars.nosqlunit.cassandra;

public class EmbeddedCassandraConfigurationBuilder {

	private static final String LOCALHOST = "127.0.0.1";
	private static final int DEFAULT_PORT= EmbeddedCassandraLifecycleManager.DEFAULT_PORT;
	
	private CassandraConfiguration cassandraConfiguration;
	
	private EmbeddedCassandraConfigurationBuilder() {
		this.cassandraConfiguration = new CassandraConfiguration();
		this.cassandraConfiguration.setHost(LOCALHOST);
		this.cassandraConfiguration.setPort(DEFAULT_PORT);
	}
	
	public static EmbeddedCassandraConfigurationBuilder newEmbeddedCassandraConfiguration() {
		return new EmbeddedCassandraConfigurationBuilder();
	}
	
	public EmbeddedCassandraConfigurationBuilder port(int port) {
		this.cassandraConfiguration.setPort(port);
		return this;
	}
	
	public EmbeddedCassandraConfigurationBuilder connectionIdentifier(String connectionIdentifier) {
		this.cassandraConfiguration.setConnectionIdentifier(connectionIdentifier);
		return this;
	}
	
	public EmbeddedCassandraConfigurationBuilder clusterName(String clusterName) {
		this.cassandraConfiguration.setClusterName(clusterName);
		return this;
	}
	
	public CassandraConfiguration build() {
		if(this.cassandraConfiguration.getClusterName() == null) {
			throw new IllegalArgumentException("Cluster name cannot be null");
		}
		return this.cassandraConfiguration;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy