Browse Source

Add Charset overload for Mustache template encoding

Add setCharset(Charset) overload to MustacheResourceTemplateLoader
while keeping setCharset(String) for backward compatibility. The
String-based method is deprecated in favor of the Charset variant.

Also deprecate MustacheProperties.getCharsetName() as it's primarily
used with the deprecated setCharset(String) method.

This change maintains backward compatibility while providing a more
type-safe API that aligns with modern Java standards.

See gh-48347

Signed-off-by: djlee <ddongjunn@gmail.com>
pull/48347/head
djlee 2 weeks ago
parent
commit
164115ce5a
  1. 6
      module/spring-boot-mustache/src/main/java/org/springframework/boot/mustache/autoconfigure/MustacheProperties.java
  2. 11
      module/spring-boot-mustache/src/main/java/org/springframework/boot/mustache/autoconfigure/MustacheResourceTemplateLoader.java

6
module/spring-boot-mustache/src/main/java/org/springframework/boot/mustache/autoconfigure/MustacheProperties.java

@ -124,6 +124,12 @@ public class MustacheProperties { @@ -124,6 +124,12 @@ public class MustacheProperties {
return this.charset;
}
/**
* Get the charset name.
* @return the charset name
* @deprecated since 4.1.0 in favor of {@link #getCharset()}
*/
@Deprecated(since = "4.1.0")
public String getCharsetName() {
return this.charset.name();
}

11
module/spring-boot-mustache/src/main/java/org/springframework/boot/mustache/autoconfigure/MustacheResourceTemplateLoader.java

@ -62,6 +62,17 @@ public class MustacheResourceTemplateLoader implements TemplateLoader, ResourceL @@ -62,6 +62,17 @@ public class MustacheResourceTemplateLoader implements TemplateLoader, ResourceL
/**
* Set the charset.
* @param charSet the charset
* @deprecated since 4.1.0 in favor of {@link #setCharset(Charset)}
*/
@Deprecated(since = "4.1.0")
public void setCharset(String charSet) {
this.charSet = Charset.forName(charSet);
}
/**
* Set the charset.
* @param charSet the charset
* @since 4.1.0
*/
public void setCharset(Charset charSet) {
this.charSet = charSet;

Loading…
Cancel
Save