@Override public int compareTo(@NonNull MessageKey another){
  int equal=0;
  int result;
  int idCompare=Integer.compare(this.id,another.id);
  if (idCompare == equal) {
    result=equal;
  }
 else {
    idCompare=-idCompare;
    int priorityCompare=Integer.compare(this.priority,another.priority);
    if (priorityCompare == equal) {
      result=idCompare;
    }
 else {
      result=priorityCompare;
    }
  }
  return result;
}

@ Override public int compareTo ( @ NonNull MessageKey another ) { int equal = 0 ; int result ; int idCompare = Integer . compare ( this . id , another . id ) ; if ( idCompare == equal ) { result = equal ; } else { idCompare = - idCompare ; int priorityCompare = Integer . compare ( this . priority , another . priority ) ; if ( priorityCompare == equal ) { result = idCompare ; } else { result = priorityCompare ; } } return result ; }
used to treemap balancing and ordering by priority but also used by treemap get ( ) method . it matches the key with the same id disregarding it ' s priority . the ordering is priority first , most recent second . most recent messages appear on top unless exists a higher priority message .
