com.tngtech.propertyloader.impl.DefaultPropertyLocationContainer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of property-loader Show documentation
Show all versions of property-loader Show documentation
The property loader is a java library for managing property configurations.
package com.tngtech.propertyloader.impl;
import com.tngtech.propertyloader.impl.interfaces.PropertyLoaderOpener;
import com.tngtech.propertyloader.impl.interfaces.PropertyLocationsContainer;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
public class DefaultPropertyLocationContainer implements PropertyLocationsContainer {
private final PropertyLoaderFactory propertyLoaderFactory;
private final List openers = new ArrayList<>();
public DefaultPropertyLocationContainer(PropertyLoaderFactory propertyLoaderFactory) {
this.propertyLoaderFactory = propertyLoaderFactory;
}
public List getOpeners() {
return openers;
}
public DefaultPropertyLocationContainer atDefaultLocations() {
atCurrentDirectory();
atContextClassPath();
atHomeDirectory();
return this;
}
public DefaultPropertyLocationContainer atCurrentDirectory() {
openers.add(propertyLoaderFactory.getURLFileOpener());
return this;
}
public DefaultPropertyLocationContainer atHomeDirectory() {
openers.add(propertyLoaderFactory.getURLFileOpener(System.getProperty("user.home")));
return this;
}
public DefaultPropertyLocationContainer atDirectory(String directory) {
openers.add(propertyLoaderFactory.getURLFileOpener(directory));
return this;
}
public DefaultPropertyLocationContainer atContextClassPath() {
openers.add(propertyLoaderFactory.getContextClassLoaderOpener());
return this;
}
public DefaultPropertyLocationContainer atRelativeToClass(Class> reference) {
openers.add(propertyLoaderFactory.getRelativeToClass(reference));
return this;
}
public DefaultPropertyLocationContainer atClassLoader(ClassLoader classLoader) {
openers.add(propertyLoaderFactory.getClassLoaderOpener(classLoader));
return this;
}
public DefaultPropertyLocationContainer atBaseURL(URL url) {
openers.add(propertyLoaderFactory.getURLFileOpener(url));
return this;
}
public DefaultPropertyLocationContainer clear() {
openers.clear();
return this;
}
}