liquibase.Labels Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of liquibase-core Show documentation
Show all versions of liquibase-core Show documentation
Liquibase is a tool for managing and executing database changes.
package liquibase;
import liquibase.util.StringUtil;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.Set;
public class Labels {
private final Set labels = new LinkedHashSet<>();
public Labels() {
}
public Labels(String... labels) {
if (labels.length == 1) {
parseLabelString(labels[0]);
} else {
for (String label : labels) {
this.labels.add(label.toLowerCase());
}
}
}
public Labels(String labels) {
parseLabelString(labels);
}
private void parseLabelString(String labels) {
labels = StringUtil.trimToNull(labels);
if (labels == null) {
return;
}
for (String label : StringUtil.splitAndTrim(labels, ",")) {
this.labels.add(label.toLowerCase());
}
}
public Labels(Collection labels) {
if (labels != null) {
for (String label : labels) {
this.labels.add(label.toLowerCase());
}
}
}
public boolean add(String label) {
return this.labels.add(label.toLowerCase());
}
public boolean remove(String label) {
return this.labels.remove(label.toLowerCase());
}
@Override
public String toString() {
return StringUtil.join(new LinkedHashSet<>(this.labels),",");
}
public boolean isEmpty() {
return this.labels.isEmpty();
}
public Set getLabels() {
return Collections.unmodifiableSet(labels);
}
}