com.xlrit.gears.base.choice.SearchParts Maven / Gradle / Ivy
package com.xlrit.gears.base.choice;
public record SearchParts(String mode, String searchText) {
public static final String SEP = "\u241E"; // U+241E: Record Separator
public String toFilter() {
return mode + SEP + searchText;
}
public static SearchParts extract(String filter, String fallback) {
if (filter == null || filter.isBlank()) return null;
int colon = filter.indexOf(SEP);
if (colon <= 0) return new SearchParts(fallback, filter);
String mode = filter.substring(0, colon);
String searchText = filter.substring(colon + 1);
return new SearchParts(mode, searchText);
}
}