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

com.versionone.apiclient.services.QueryVariable Maven / Gradle / Ivy

Go to download

A library for custom Java development against the VersionOne Development Platform's REST API.

There is a newer version: 16.1.3
Show newest version
package com.versionone.apiclient.services;

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

import com.versionone.apiclient.interfaces.IValueProvider;

public class QueryVariable implements IValueProvider {
    public final String name;
    private final List values = new ArrayList();

    public QueryVariable(String name, Object... values) {
        Collections.addAll(this.values, values);
        this.name = name;
    }

    public List getValues() {
        return values;
    }

    public String getToken() {
        return  String.format("$%s", name);
    }

    public String stringize() {
        return getToken();
    }

    public void merge(IValueProvider valueProvider) {
        throw new UnsupportedOperationException("We do not merge variables with anything else until we're sure we should do.");
    }

    public Boolean canMerge() {
        return false;
    }
    
    public String toString(){
        return String.format("%s=%s", getToken(), TextBuilder.join(values, ",", TextBuilder.STRINGIZER_DELEGATE.build(new ValueStringizer(""), "stringize")));
    }
}