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

org.fuchss.objectcasket.tablemodule.impl.ModuleConfigurationImpl Maven / Gradle / Ivy

Go to download

Object Casket is a simple O/R mapper that can be used together with the Java Persistence API (JPA). The aim is to provide a simple solution for small projects to store multi-related entities in a simple manner.

There is a newer version: 0.20.17
Show newest version
package org.fuchss.objectcasket.tablemodule.impl;

import java.sql.Driver;
import java.util.EnumMap;
import java.util.Map;

import org.fuchss.objectcasket.common.CasketException;
import org.fuchss.objectcasket.sqlconnector.port.DBConfiguration;
import org.fuchss.objectcasket.sqlconnector.port.SqlDialect;
import org.fuchss.objectcasket.tablemodule.port.ModuleConfiguration;

@SuppressWarnings("java:S6206") // identity not equality is needed!
class ModuleConfigurationImpl implements ModuleConfiguration {

	private final DBConfiguration config;

	private static final Map flagMap = new EnumMap<>(ModuleConfiguration.Flag.class);

	static {
		flagMap.put(ModuleConfiguration.Flag.CREATE, DBConfiguration.Flag.CREATE);
		flagMap.put(ModuleConfiguration.Flag.MODIFY, DBConfiguration.Flag.MODIFY);
	}

	public ModuleConfigurationImpl(DBConfiguration config) {
		this.config = config;
	}

	public DBConfiguration getConfig() {
		return this.config;
	}

	@Override
	public boolean setDriver(Class driver, String driverPrefix, SqlDialect dialect) throws CasketException {
		return this.config.setDriver(driver, driverPrefix, dialect);

	}

	@Override
	public boolean setUri(String uri) throws CasketException {

		return this.config.setUri(uri);

	}

	@Override
	public boolean setUser(String name) throws CasketException {

		return this.config.setUser(name);

	}

	@Override
	public boolean setPassword(String name) throws CasketException {

		return this.config.setPassword(name);

	}

	@Override
	public boolean setFlag(Flag... flags) throws CasketException {
		DBConfiguration.Flag[] dbFlags = new DBConfiguration.Flag[flags.length];
		for (int idx = 0; idx < dbFlags.length; idx++)
			dbFlags[idx] = flagMap.get(flags[idx]);

		return this.config.setFlag(dbFlags);

	}

	@Override
	public boolean removeFlag(Flag... flags) throws CasketException {
		DBConfiguration.Flag[] dbFlags = new DBConfiguration.Flag[flags.length];
		for (int idx = 0; idx < dbFlags.length; idx++)
			dbFlags[idx] = flagMap.get(flags[idx]);

		return this.config.removeFlag(dbFlags);

	}

	@Override
	public boolean containsAll(Flag... flags) throws CasketException {
		DBConfiguration.Flag[] dbFlags = new DBConfiguration.Flag[flags.length];
		for (int idx = 0; idx < dbFlags.length; idx++)
			dbFlags[idx] = flagMap.get(flags[idx]);

		return this.config.containsAll(dbFlags);

	}

	@Override
	public boolean inUse() {
		return this.config.isInUse();
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy