(search) Rename SearchProfile.name into filterId

Avoid foot-gun caused by name clash with the Enumeration method name(), which returns the Java name of the enumeration value.
This commit is contained in:
Viktor Lofgren 2023-11-22 17:31:27 +01:00
parent 251174c9a2
commit 5639f0653d
3 changed files with 7 additions and 7 deletions

View file

@ -8,7 +8,7 @@ import java.nio.charset.StandardCharsets;
public record SearchParameters(String query, SearchProfile profile, SearchJsParameter js) {
public String profileStr() {
return profile.name;
return profile.filterId;
}
public SearchParameters withProfile(SearchProfile profile) {
@ -22,7 +22,7 @@ public record SearchParameters(String query, SearchProfile profile, SearchJsPara
public String renderUrl(WebsiteUrl baseUrl) {
String path = String.format("/search?query=%s&profile=%s&js=%s",
URLEncoder.encode(query, StandardCharsets.UTF_8),
URLEncoder.encode(profile.name, StandardCharsets.UTF_8),
URLEncoder.encode(profile.filterId, StandardCharsets.UTF_8),
URLEncoder.encode(js.value, StandardCharsets.UTF_8));
return baseUrl.withPath(path);

View file

@ -22,7 +22,7 @@ public class DecoratedSearchResults {
return params.query();
}
public String getProfile() {
return params.profile().name;
return params.profile().filterId;
}
public String getJs() {
return params.js().value;

View file

@ -27,11 +27,11 @@ public enum SearchProfile {
;
public final String name;
public final String filterId;
public final SearchSetIdentifier searchSetIdentifier;
SearchProfile(String name, SearchSetIdentifier searchSetIdentifier) {
this.name = name;
SearchProfile(String filterId, SearchSetIdentifier searchSetIdentifier) {
this.filterId = filterId;
this.searchSetIdentifier = searchSetIdentifier;
}
@ -42,7 +42,7 @@ public enum SearchProfile {
}
for (var profile : values) {
if (Objects.equals(profile.name, param)) {
if (Objects.equals(profile.filterId, param)) {
return profile;
}
}