All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.xlrit.gears.base.choice.SearchParts Maven / Gradle / Ivy

There is a newer version: 1.17.5
Show newest version
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);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy