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

com.voximplant.apiclient.util.MultiArgument Maven / Gradle / Ivy

Go to download

Voximplant Java API client library. Voximplant is a cloud communications platform for business and developers

There is a newer version: 1.11.0
Show newest version
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 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 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