package org.lumongo.server.searching;

public class FacetCountResult implements Comparable<FacetCountResult> {
	private String facet;
	private long count;
	
	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) {
        int compareCount = Long.compare(this.count, o.count);
        if (compareCount == 0) {
            return this.facet.compareTo(o.facet);
        }
        return compareCount;
    }

	    
    @Override
    public boolean equals(Object obj) {
        if (obj instanceof FacetCountResult) {
            return (compareTo((FacetCountResult) obj) == 0);
        }
        return false;
    }
    
    @Override
    public int hashCode() {     
        return facet.hashCode() + (int)count;
    }
}

@@ -148,17 +148,16 @@
  count;%0A
-%09
 %0A%09public
@@ -241,33 +241,32 @@
 unt = count;%0A%09%7D%0A
-%09
 %0A%09public String 
@@ -289,33 +289,32 @@
 eturn facet;%0A%09%7D%0A
-%09
 %0A%09public void se
@@ -357,25 +357,24 @@
 = facet;%0A%09%7D%0A
-%09
 %0A%09public lon
@@ -407,17 +407,16 @@
 unt;%0A%09%7D%0A
-%09
 %0A%09public
@@ -473,14 +473,10 @@
 %0A%09%7D%0A
+%0A
 %09
-%0A    
 @Ove
@@ -473,36 +473,33 @@
 %0A%09%7D%0A%0A%09@Override%0A
-    
+%09
 public int compa
@@ -525,24 +525,18 @@
 lt o) %7B%0A
-        
+%09%09
 int comp
@@ -581,24 +581,18 @@
 count);%0A
-        
+%09%09
 if (comp
@@ -604,36 +604,27 @@
 unt == 0) %7B%0A
-            
+%09%09%09
 return this.
@@ -653,32 +653,25 @@
 t);%0A
-        %7D%0A        
+%09%09%7D%0A%09%09
 return
+ -1 *
  com
@@ -685,25 +685,14 @@
 nt;%0A
-    %7D%0A%0A%09    %0A    
+%09%7D%0A%0A%0A%09
 @Ove
@@ -693,28 +693,25 @@
 %0A%09@Override%0A
-    
+%09
 public boole
@@ -734,24 +734,18 @@
  obj) %7B%0A
-        
+%09%09
 if (obj 
@@ -779,20 +779,11 @@
 ) %7B%0A
-            
+%09%09%09
 retu
@@ -831,55 +831,33 @@
 0);%0A
-        %7D%0A        return false;%0A    %7D%0A    %0A    
+%09%09%7D%0A%09%09return false;%0A%09%7D%0A%0A%09
 @Ove
@@ -862,20 +862,17 @@
 verride%0A
-    
+%09
 public i
@@ -890,22 +890,11 @@
 () %7B
-     %0A        
+%0A%09%09
 retu
@@ -931,12 +931,9 @@
 nt;%0A
-    
+%09
 %7D%0A%7D%0A

make facet results ordered from greatest to least