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

org.kairosdb.client.builder.grouper.BinGrouper Maven / Gradle / Ivy

There is a newer version: 3.1.0
Show newest version
package org.kairosdb.client.builder.grouper;

import com.google.gson.annotations.SerializedName;
import org.kairosdb.client.builder.Grouper;

import java.util.Arrays;
import java.util.List;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;

public class BinGrouper extends Grouper
{

	@SerializedName("bins")
	private Double[] bins;

	public BinGrouper(Double... bins)
	{
		super("bin");

		checkNotNull(bins, "bins cannot be null");
		checkArgument(bins.length > 0, "bins cannot be empty");
		this.bins = bins;
	}

	public BinGrouper(List bins)
	{
		super("bin");
		checkNotNull(bins, "bins cannot be null");
		checkArgument(bins.size() > 0, "bins cannot be empty");
		this.bins = (Double[]) bins.toArray();
	}

	public List getBins()
	{
		return Arrays.asList(bins);
	}

	@Override
	public boolean equals(Object o)
	{
		if (this == o) return true;
		if (o == null || getClass() != o.getClass()) return false;
		if (!super.equals(o)) return false;

		BinGrouper that = (BinGrouper) o;
		return Arrays.equals(bins, that.bins);
	}

	@Override
	public int hashCode()
	{
		int result = super.hashCode();
		result = 31 * result + Arrays.hashCode(bins);
		return result;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy