Android Open Source - BaseAndroid Custom Catalog Comparator






From Project

Back to project page BaseAndroid.

License

The source code is released under:

MIT License

If you think the Android project BaseAndroid listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/**
 * File: CustomCatalogComparator/*w w w.j  a v a  2  s.  c  o  m*/
 * CreationDate: 04/09/13
 * Author: "M. en C. Javier Silva Perez (JSP)"
 * Description: 
 *
 */
package com.cmovil.baseandroid.util;

import com.cmovil.baseandroid.model.db.BaseModel;

import java.util.Comparator;

/**
 * Custom comparator for catalog elements, this will compare catalog descriptions
 *
 * @author "M. en C. Javier Silva Perez (JSP)"
 * @version 1.0
 * @since 04/09/13
 */
public class CustomCatalogComparator<T extends BaseModel> implements Comparator<T> {

  /**
   * Compares the two specified objects to determine their relative ordering. The ordering
   * implied by the return value of this method for all possible pairs of
   * {@code (lhs, rhs)} should form an <i>equivalence relation</i>.
   * This means that
   * <ul>
   * <li>{@code compare(a, a)} returns zero for all {@code a}</li>
   * <li>the sign of {@code compare(a, b)} must be the opposite of the sign of {@code
   * compare(b, a)} for all pairs of (a,b)</li>
   * <li>From {@code compare(a, b) > 0} and {@code compare(b, c) > 0} it must
   * follow {@code compare(a, c) > 0} for all possible combinations of {@code
   * (a, b, c)}</li>
   * </ul>
   *
   * @param lhs
   *   an {@code Object}.
   * @param rhs
   *   a second {@code Object} to compare with {@code lhs}.
   * @return an integer < 0 if {@code lhs} is less than {@code rhs}, 0 if they are
   * equal, and > 0 if {@code lhs} is greater than {@code rhs}.
   *
   * @throws ClassCastException
   *   if objects are not of the correct type.
   */
  @Override
  public int compare(T lhs, T rhs) {
    String lhsDescription = lhs.getShownDescription().toUpperCase();
    String rhsDescription = rhs.getShownDescription().toUpperCase();
    return lhsDescription.compareTo(rhsDescription);
  }
}




Java Source Code List

com.cmovil.baseandroid.controller.BaseDBController.java
com.cmovil.baseandroid.controller.SampleController.java
com.cmovil.baseandroid.dao.db.BaseDBDAO.java
com.cmovil.baseandroid.dao.db.DBException.java
com.cmovil.baseandroid.dao.db.DatabaseDictionary.java
com.cmovil.baseandroid.dao.db.SampleDAO.java
com.cmovil.baseandroid.dao.db.helper.BaseDatabaseOpenHelper.java
com.cmovil.baseandroid.dao.db.helper.SampleOpenHelper.java
com.cmovil.baseandroid.dao.ws.BaseMessageWS.java
com.cmovil.baseandroid.dao.ws.InvalidResponseException.java
com.cmovil.baseandroid.dao.ws.WSClient.java
com.cmovil.baseandroid.model.db.BaseModel.java
com.cmovil.baseandroid.model.db.State.java
com.cmovil.baseandroid.model.ws.MessageErrorCode.java
com.cmovil.baseandroid.model.ws.Parser.java
com.cmovil.baseandroid.util.CMUtils.java
com.cmovil.baseandroid.util.CustomCatalogComparator.java
com.cmovil.baseandroid.util.KeyDictionary.java
com.cmovil.baseandroid.view.BaseActionBarActivity.java
com.cmovil.baseandroid.view.BaseDrawerActivity.java
com.cmovil.baseandroid.view.SplashActivity.java