kairosdb-client icon indicating copy to clipboard operation
kairosdb-client copied to clipboard

On Varargs

Open BrentonPoke opened this issue 5 years ago • 3 comments

This is mainly a stylistic question, but instead of varargs values, wouldn't most just make a set? I can't imagine a scenario where you would want duplicate values for a tag, and a set could force uniqueness.

public QueryTagMetric addTag(String name, String... values)
	{
		checkNotNullOrEmpty(name, "name cannot be null or empty");
		checkArgument(values.length > 0, "value must be greater than 0");

		for (String value : values)
		{
			checkNotNullOrEmpty(value, "value cannot be null or empty");
		}

		tags.putAll(name, Arrays.asList(values));

		return (this);
	}

BrentonPoke avatar Jul 16 '19 21:07 BrentonPoke

You are correct. The code should be fixed to ensure tags are unique.

jsabin avatar Jul 21 '19 00:07 jsabin

@jsabin What do you think about my PR?

BrentonPoke avatar Aug 01 '19 10:08 BrentonPoke

Was this ever going to get merged?

BrentonPoke avatar Apr 23 '21 11:04 BrentonPoke

Yeah just merged it. Didn't realize how long this was sitting round.

brianhks avatar Mar 22 '24 22:03 brianhks