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

com.xqbase.metric.common.MetricKey Maven / Gradle / Ivy

Go to download

a lightweight metric framework for aggregating, collecting and showing metric data - common part

There is a newer version: 0.2.13
Show newest version
package com.xqbase.metric.common;

import java.util.HashMap;

public class MetricKey {
	private String name;
	private HashMap tagMap;

	public MetricKey(String name, HashMap tagMap) {
		this.name = name;
		this.tagMap = tagMap;
	}

	public MetricKey(String name, String... tagPairs) {
		this.name = name;
		tagMap = new HashMap<>();
		for (int i = 0; i < tagPairs.length - 1; i += 2) {
			String key = tagPairs[i];
			String value = tagPairs[i + 1];
			if (key != null && value != null) {
				tagMap.put(key, value);
			}
		}
	}

	public String getName() {
		return name;
	}

	public HashMap getTagMap() {
		return tagMap;
	}

	@Override
	public boolean equals(Object obj) {
		MetricKey metricKey = (MetricKey) obj;
		return metricKey.name.equals(name) && metricKey.tagMap.equals(tagMap);
	}

	@Override
	public int hashCode() {
		return name.hashCode() + tagMap.hashCode();
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy