From 7031035301a5b246a72445eb36309be82f6d0165 Mon Sep 17 00:00:00 2001 From: oeljeklaus-you Date: Sat, 23 Jun 2018 20:38:35 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=8C=E6=AC=A1=E6=8E=92=E5=BA=8F=E7=B1=BB?= =?UTF-8?q?=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/workspace.xml | 72 +++++++---- .../cn/edu/hust/session/CategorySortKey.java | 112 ++++++++++++++++++ 2 files changed, 163 insertions(+), 21 deletions(-) create mode 100644 src/main/java/cn/edu/hust/session/CategorySortKey.java diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 7705263..34d6455 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,8 +2,8 @@ - - + + @@ -16,7 +16,7 @@ - + @@ -61,6 +61,29 @@ + + + + + + + + + + + + + + + + + + + + + + + @@ -142,6 +165,8 @@ @@ -247,15 +272,6 @@ - - - - - - - - - @@ -578,7 +594,7 @@ - + 1529592741848 @@ -630,7 +646,7 @@ - @@ -739,13 +755,6 @@ - - - - - - - @@ -1381,6 +1390,27 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/cn/edu/hust/session/CategorySortKey.java b/src/main/java/cn/edu/hust/session/CategorySortKey.java new file mode 100644 index 0000000..3fa8435 --- /dev/null +++ b/src/main/java/cn/edu/hust/session/CategorySortKey.java @@ -0,0 +1,112 @@ +package cn.edu.hust.session; + +import scala.math.Ordered; + +public class CategorySortKey implements Ordered { + + private Long clickCount; + private Long orderCount; + private Long payCount; + + @Override + public int compare(CategorySortKey categorySortKey) { + if(clickCount-categorySortKey.getClickCount()!=0) + { + return (int) (clickCount-categorySortKey.getClickCount()); + }else if(clickCount-categorySortKey.getClickCount()==0&&orderCount-categorySortKey.getOrderCount()!=0) + { + return (int) (orderCount-categorySortKey.getOrderCount()); + } + else if(clickCount-categorySortKey.getClickCount()==0&&orderCount-categorySortKey.getOrderCount()==0&&payCount-categorySortKey.getPayCount()!=0) + return (int) (payCount-categorySortKey.getPayCount()); + return 0; + } + + @Override + public boolean $less(CategorySortKey categorySortKey) { + if(clickCountcategorySortKey.getClickCount()) + { + return true; + }else if(clickCount==categorySortKey.getClickCount()&&orderCount>categorySortKey.getOrderCount()) + { + return true; + } + else if(clickCount==categorySortKey.getClickCount()&&orderCount==categorySortKey.getOrderCount()&&payCount>categorySortKey.getPayCount()) + return true; + + return false; + } + + @Override + public boolean $less$eq(CategorySortKey categorySortKey) { + if($less(categorySortKey)) + { + return true; + } + else if(clickCount==categorySortKey.getClickCount()&&orderCount==categorySortKey.getOrderCount()&&payCount==categorySortKey.getPayCount()) + return true; + return false; + } + + @Override + public boolean $greater$eq(CategorySortKey categorySortKey) { + if($greater(categorySortKey)) + { + return true; + }else if(clickCount==categorySortKey.getClickCount()&&orderCount==categorySortKey.getOrderCount()&&payCount==categorySortKey.getPayCount()) + return true; + return false; + } + + @Override + public int compareTo(CategorySortKey categorySortKey) { + if(clickCount-categorySortKey.getClickCount()!=0) + { + return (int) (clickCount-categorySortKey.getClickCount()); + }else if(clickCount-categorySortKey.getClickCount()==0&&orderCount-categorySortKey.getOrderCount()!=0) + { + return (int) (orderCount-categorySortKey.getOrderCount()); + } + else if(clickCount-categorySortKey.getClickCount()==0&&orderCount-categorySortKey.getOrderCount()==0&&payCount-categorySortKey.getPayCount()!=0) + return (int) (payCount-categorySortKey.getPayCount()); + return 0; + } + + public Long getClickCount() { + return clickCount; + } + + public void setClickCount(Long clickCount) { + this.clickCount = clickCount; + } + + public Long getOrderCount() { + return orderCount; + } + + public void setOrderCount(Long orderCount) { + this.orderCount = orderCount; + } + + public Long getPayCount() { + return payCount; + } + + public void setPayCount(Long payCount) { + this.payCount = payCount; + } +}