CategoryToStringConverter.java

package ui.assembly64;

import javafx.util.StringConverter;

import java.util.ResourceBundle;

public class CategoryToStringConverter<T> extends StringConverter<Category> {

    private final ResourceBundle bundle;

    public CategoryToStringConverter(ResourceBundle bundle) {
        this.bundle = bundle;
    }

    @Override
    public Category fromString(String repoString) {
        throw new RuntimeException("This function is not supported!");
    }

    @Override
    public String toString(Category subCategory) {
        if (subCategory == null) return "";
        return !subCategory.equals(Category.ALL) ? subCategory.getName() : bundle.getString("ALL_CONTENT");
    }

}