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

devutility.internal.dao.RedisInstanceUtils Maven / Gradle / Ivy

There is a newer version: 1.3.8.1
Show newest version
package devutility.internal.dao;

import java.util.Properties;

import devutility.internal.dao.models.RedisInstance;
import devutility.internal.util.PropertiesUtils;

public final class RedisInstanceUtils extends DbInstanceUtils {
	/**
	 * Create an RedisInstance instance with configuration in properties file.
	 * @param propertiesFile: Properties file name.
	 * @param prefix: Prefix of item configuration in properties file.
	 * @return RedisInstance
	 */
	public static RedisInstance getInstance(String propertiesFile, String prefix) {
		Properties properties = PropertiesUtils.getProperties(propertiesFile);

		if (properties == null) {
			return null;
		}

		return getInstance(properties, prefix);
	}

	/**
	 * Create an RedisInstance instance with configuration in properties object.
	 * @param properties: Properties object.
	 * @param prefix: Prefix of item configuration in properties file.
	 * @return RedisInstance
	 */
	public static RedisInstance getInstance(Properties properties, String prefix) {
		RedisInstance instance = new RedisInstance();
		setInstance(instance, properties, prefix);

		int dbIndex = PropertiesUtils.getIntProperty(properties, getPropertyKeyDBIndex(prefix));
		instance.setDBIndex(dbIndex);
		return instance;
	}

	/**
	 * Get property key of dbindex.
	 * @param prefix: Prefix of item configuration in properties file.
	 * @return String
	 */
	public static String getPropertyKeyDBIndex(String prefix) {
		return String.format("%s.dbindex", prefix);
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy