com.voximplant.apiclient.util.MultiArgument Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of apiclient Show documentation
Show all versions of apiclient Show documentation
Voximplant Java API client library. Voximplant is a cloud communications platform for business and developers
package com.voximplant.apiclient.util;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.stream.Collectors;
public class MultiArgument {
private MultiArgument(Collection extends T> values) {
this.values = new LinkedList(values);
}
private MultiArgument(T value) {
this.values = Collections.singletonList(value);
}
private MultiArgument(boolean any) {
this.any = any;
}
public static MultiArgument forSingleValue(T v) {
return new MultiArgument(v);
}
public static MultiArgument forMultipleValues(Collection extends T> v) {
return new MultiArgument(v);
}
public static MultiArgument forAllValues() {
return new MultiArgument(true);
}
public String toString() {
if (this.any) {
return "all";
}
if (this.values == null)
return "";
return this.values.stream().map(Object::toString).collect(Collectors.joining(";"));
}
boolean hasValue() {
return this.any || (this.values != null && this.values.size() > 0);
}
List values;
boolean any;
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy