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

org.lumongo.server.search.FacetCountResult Maven / Gradle / Ivy

There is a newer version: 0.52
Show newest version
package org.lumongo.server.search;

import java.util.Comparator;

public class FacetCountResult implements Comparable {
	private String facet;
	private long count;

	public static Comparator COUNT_THEN_FACET_COMPARE = Comparator.comparingLong(FacetCountResult::getCount).reversed().thenComparing(FacetCountResult::getFacet);

	public FacetCountResult(String facet, long count) {
		this.facet = facet;
		this.count = count;
	}

	public String getFacet() {
		return facet;
	}

	public void setFacet(String facet) {
		this.facet = facet;
	}

	public long getCount() {
		return count;
	}

	public void setCount(long count) {
		this.count = count;
	}

	@Override
	public int compareTo(FacetCountResult o) {
		return COUNT_THEN_FACET_COMPARE.compare(this, o);
	}

	@Override
	public boolean equals(Object obj) {
		if (obj instanceof FacetCountResult) {
			return (compareTo((FacetCountResult) obj) == 0);
		}
		return false;
	}

	@Override
	public int hashCode() {
		return facet.hashCode() + Long.hashCode(count);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy