Class CountryDecoder

  • All Implemented Interfaces:
    java.util.Comparator<com.mukesh.countrypicker.models.Country>

    public class CountryDecoder
    extends java.lang.Object
    implements java.util.Comparator<com.mukesh.countrypicker.models.Country>
    This is used as a helper class in decoding R.string.countries that are base64 encoded to avoid special characters.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  CountryDecoder.BaseCountry
      BaseCountry class
    • Constructor Summary

      Constructors 
      Constructor Description
      CountryDecoder()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int compare​(com.mukesh.countrypicker.models.Country lhs, com.mukesh.countrypicker.models.Country rhs)
      Comparator for sorting countries by name.
      static java.lang.String getCountryCode​(java.lang.String countryName)
      Gets the country code of a given country (as per CountryPicker implementation)
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.util.Comparator

        equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
    • Constructor Detail

      • CountryDecoder

        public CountryDecoder()
    • Method Detail

      • getCountryCode

        public static java.lang.String getCountryCode​(java.lang.String countryName)
        Gets the country code of a given country (as per CountryPicker implementation)
        Parameters:
        countryName - name of the country to lookup
        Returns:
        country code found using the passed country name. If none found return US
      • compare

        public int compare​(com.mukesh.countrypicker.models.Country lhs,
                           com.mukesh.countrypicker.models.Country rhs)
        Comparator for sorting countries by name.
        Specified by:
        compare in interface java.util.Comparator<com.mukesh.countrypicker.models.Country>
        Parameters:
        lhs - left-hand side
        rhs - right-hand side
        Returns:
        positive integer when lhs is greater than rhs, else negative integer