private CharSequence formatColor ( final ColorFormat colorFormat , @ ColorInt final int color ) { Condition . INSTANCE . ensureNotNull ( colorFormat , "The color format may not be null" ) ; if ( colorFormat == ColorFormat . RGB ) { return String . format ( Locale . getDefault ( ) , "R = %d, G = %d, B = %d" , Color . red ( color ) , Color . green ( color ) , Color . blue ( color ) ) ; } else if ( colorFormat == ColorFormat . ARGB ) { return String . format ( Locale . getDefault ( ) , "A = %d, R = %d, G = %d, B = %d" , Color . alpha ( color ) , Color . red ( color ) , Color . green ( color ) , Color . blue ( color ) ) ; } else if ( colorFormat == ColorFormat . HEX_3_BYTES ) { return String . format ( "#%06X" , ( 0xFFFFFF & color ) ) ; } else { return String . format ( "#%08X" , ( color ) ) ; } }
Creates and returns a textual representation of a color according to a specific format .