class FilterLibraryImpl implements FilterLibrary {

    private final Workspace workspace;
    private final AbstractLookup lookup;
    private final InstanceContent content;
    private final Map<Class<? extends Filter>, FilterBuilder> buildersMap;

    public FilterLibraryImpl(Workspace workspace) {
        this.workspace = workspace;
        content = new InstanceContent();
        lookup = new AbstractLookup(content);

        for (FilterBuilder builder : Lookup.getDefault().lookupAll(FilterBuilder.class)) {
            content.add(builder);
        }

        for (Query query : Lookup.getDefault().lookupAll(Query.class)) {
            content.add(query);
        }

        for (CategoryBuilder catBuilder : Lookup.getDefault().lookupAll(CategoryBuilder.class)) {
            content.add(catBuilder);
        }

        buildersMap = new HashMap<>();
    }

    private void buildBuildersMap() {<FILL_FUNCTION_BODY>}

    @Override
    public Lookup getLookup() {
        return lookup;
    }

    @Override
    public void addBuilder(FilterBuilder builder) {
        content.add(builder);
    }

    @Override
    public void removeBuilder(FilterBuilder builder) {
        content.remove(builder);
    }

    @Override
    public void registerMask(FilterLibraryMask mask) {
        content.add(mask);
    }

    @Override
    public void unregisterMask(FilterLibraryMask mask) {
        content.remove(mask);
    }

    @Override
    public FilterBuilder getBuilder(Filter filter) {
        buildBuildersMap();
        if (buildersMap.get(filter.getClass()) != null) {
            return buildersMap.get(filter.getClass());
        }
        return null;
    }

    @Override
    public void saveQuery(Query query) {
        content.add(query);
    }

    @Override
    public void deleteQuery(Query query) {
        content.remove(query);
    }
}


        for (FilterBuilder builder : lookup.lookupAll(FilterBuilder.class)) {
            try {
                Filter f = builder.getFilter(workspace);
                buildersMap.put(f.getClass(), builder);
                builder.destroy(f);
            } catch (Exception e) {
            }
        }
        for (CategoryBuilder catBuilder : Lookup.getDefault().lookupAll(CategoryBuilder.class)) {
            for (FilterBuilder builder : catBuilder.getBuilders(workspace)) {
                try {
                    Filter f = builder.getFilter(workspace);
                    buildersMap.put(f.getClass(), builder);
                    builder.destroy(f);
                } catch (Exception e) {
                }
            }
        }
    
<no_super_class>