public static Label . Builder replace ( final Label . Builder label , final String oldLabel , final String newLabel ) { for ( final MapFieldEntry . Builder entryBuilder : label . getEntryBuilderList ( ) ) { final List < String > valueList = new ArrayList <> ( entryBuilder . getValueList ( ) ) ; entryBuilder . clearValue ( ) ; for ( String value : valueList ) { if ( StringProcessor . removeWhiteSpaces ( value ) . equalsIgnoreCase ( StringProcessor . removeWhiteSpaces ( oldLabel ) ) ) { entryBuilder . addValue ( newLabel ) ; } else { entryBuilder . addValue ( value ) ; } } } return label ; }
Replace all instances of a label string in a label builder . The check for the label string which should be replaced is done ignoring the case .