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

com.tngtech.propertyloader.impl.DefaultPropertySuffixContainer Maven / Gradle / Ivy

There is a newer version: 1.5.1
Show newest version
package com.tngtech.propertyloader.impl;

import com.tngtech.propertyloader.impl.helpers.HostsHelper;
import com.tngtech.propertyloader.impl.interfaces.PropertySuffixContainer;

import java.util.ArrayList;
import java.util.List;

public class DefaultPropertySuffixContainer implements PropertySuffixContainer {

    private final HostsHelper hostsHelper;

    private final List suffixes = new ArrayList<>();

    public DefaultPropertySuffixContainer(HostsHelper hostsHelper) {
        this.hostsHelper = hostsHelper;
    }

    public DefaultPropertySuffixContainer addUserName() {
        this.suffixes.add(System.getProperty("user.name"));
        return this;
    }

    public DefaultPropertySuffixContainer addLocalHostNames() {
        this.suffixes.addAll(hostsHelper.getLocalHostNames());
        return this;
    }

    public DefaultPropertySuffixContainer addString(String suffix) {
        this.suffixes.add(suffix);
        return this;
    }

    public DefaultPropertySuffixContainer addSuffixList(List suffixes) {
        this.suffixes.addAll(suffixes);
        return this;
    }

    public List getSuffixes() {
        return suffixes;
    }

    public DefaultPropertySuffixContainer addDefaultSuffixes() {
        addUserName();
        addLocalHostNames();
        addString("override");
        return this;
    }

    public DefaultPropertySuffixContainer clear() {
        suffixes.clear();
        return this;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy