public static String setOrAppend ( final String target , final String value , final boolean withSpace ) { if ( target == null ) { return value ; } if ( value == null ) { return target ; } else { if ( withSpace && ! target . endsWith ( STRING_BLANK ) ) { return target + STRING_BLANK + value ; } else { return target + value ; } } }
If target is null return the value ; else append value to target . If withSpace is true insert a blank between them .