@ Nullable private static String _getTextValueForDecimalSeparator ( @ Nullable final String sTextValue , @ Nonnull final EDecimalSeparator eDecimalSep , @ Nonnull final EGroupingSeparator eGroupingSep ) { ValueEnforcer . notNull ( eDecimalSep , "DecimalSeparator" ) ; ValueEnforcer . notNull ( eGroupingSep , "GroupingSeparator" ) ; final String ret = StringHelper . trim ( sTextValue ) ; // Replace only, if the desired decimal separator is not present if ( ret != null && ret . indexOf ( eDecimalSep . getChar ( ) ) < 0 ) switch ( eDecimalSep ) { case COMMA : { // Decimal separator is a "," if ( ret . indexOf ( ' ' ) > - 1 && eGroupingSep . getChar ( ) != ' ' ) { // Currency expects "," but user passed "." return StringHelper . replaceAll ( ret , ' ' , eDecimalSep . getChar ( ) ) ; } break ; } case POINT : { // Decimal separator is a "." if ( ret . indexOf ( ' ' ) > - 1 && eGroupingSep . getChar ( ) != ' ' ) { // Pattern contains no "," but value contains "," return StringHelper . replaceAll ( ret , ' ' , eDecimalSep . getChar ( ) ) ; } break ; } default : throw new IllegalStateException ( "Unexpected decimal separator [" + eDecimalSep + "]" ) ; } return ret ; }
Adopt the passed text value according to the requested decimal separator .