@Test public void notFoundParametersAreIgnored() { String param1Name = "wrongParamName"; String param1Value = "Somebody"; String string = "He is {{firstName}}"; String formattedString = stringUtils.applySubstitutionsToString(string, Pair.create(param1Name, param1Value)); assertThat(formattedString).isEqualTo(string); }
@SuppressWarnings("unchecked") @NonNull public String applySubstitutionsToString(@NonNull final String string, @NonNull final Pair<String, String>... substitutions) { String primaryString = string; for (final Pair<String, String> substitution : substitutions) { primaryString = primaryString.replace("{{" + substitution.first + "}}", substitution.second); } return primaryString; }
StringUtils { @SuppressWarnings("unchecked") @NonNull public String applySubstitutionsToString(@NonNull final String string, @NonNull final Pair<String, String>... substitutions) { String primaryString = string; for (final Pair<String, String> substitution : substitutions) { primaryString = primaryString.replace("{{" + substitution.first + "}}", substitution.second); } return primaryString; } }
StringUtils { @SuppressWarnings("unchecked") @NonNull public String applySubstitutionsToString(@NonNull final String string, @NonNull final Pair<String, String>... substitutions) { String primaryString = string; for (final Pair<String, String> substitution : substitutions) { primaryString = primaryString.replace("{{" + substitution.first + "}}", substitution.second); } return primaryString; } @Inject  StringUtils(); }
StringUtils { @SuppressWarnings("unchecked") @NonNull public String applySubstitutionsToString(@NonNull final String string, @NonNull final Pair<String, String>... substitutions) { String primaryString = string; for (final Pair<String, String> substitution : substitutions) { primaryString = primaryString.replace("{{" + substitution.first + "}}", substitution.second); } return primaryString; } @Inject  StringUtils(); @SuppressWarnings("unchecked") @NonNull String applySubstitutionsToString(@NonNull final String string, @NonNull final Pair<String, String>... substitutions); }
StringUtils { @SuppressWarnings("unchecked") @NonNull public String applySubstitutionsToString(@NonNull final String string, @NonNull final Pair<String, String>... substitutions) { String primaryString = string; for (final Pair<String, String> substitution : substitutions) { primaryString = primaryString.replace("{{" + substitution.first + "}}", substitution.second); } return primaryString; } @Inject  StringUtils(); @SuppressWarnings("unchecked") @NonNull String applySubstitutionsToString(@NonNull final String string, @NonNull final Pair<String, String>... substitutions);  }