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

liquibase.Contexts Maven / Gradle / Ivy

There is a newer version: 4.31.0
Show newest version
package liquibase;

import liquibase.util.StringUtils;

import java.util.*;

public class Contexts extends HashSet {

    public Contexts() {
    }

    public Contexts(String... contexts) {
        if (contexts.length == 1) {
            parseContextString(contexts[0]);
        } else {
            addAll(Arrays.asList(contexts));
        }
    }

    public Contexts(String contexts) {
        parseContextString(contexts);
    }

    private void parseContextString(String contexts) {
        contexts = StringUtils.trimToNull(contexts);

        if (contexts == null) {
            return;
        }
        addAll(StringUtils.splitAndTrim(contexts, ","));
    }

    public Contexts(Collection contexts) {
        addAll(contexts);
    }

    @Override
    public boolean add(String s) {
        return super.add(s.toLowerCase());
    }

    @Override
    public String toString() {
        return StringUtils.join(new TreeSet(this),",");
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy