class FeatureFilter {

    public FeatureCollection filter() {
        List<Feature> featuresList = builder.getFeatureCollection().features();
        ArrayList<Feature> filteredFeatures = new ArrayList<>();

        HashMap<String, Comparison> comparisons = new HashMap<>();

        EqualToComparison equalToComparison = new EqualToComparison();
        RegexComparison regexComparison = new RegexComparison();

        comparisons.put(equalToComparison.getFunctionName(), equalToComparison);
        comparisons.put(regexComparison.getFunctionName(), regexComparison);

        if (featuresList != null) {
            ArrayList<FilterCondition> filterConditions = builder.getFilterConditions();

            if (filterConditions.size() > 0) {
                for (Feature feature : featuresList) {
                    boolean skipFeature = false;
                    if (builder.getSortProperty() != null
                            && !feature.hasProperty(builder.getSortProperty())) {
                        continue;
                    }

                    for (FilterCondition filterCondition : filterConditions) {
                        String propertyName = filterCondition.getPropertyName();
                        if (feature.hasProperty(propertyName)) {
                            Comparison comparison = comparisons.get(filterCondition.getComparisionType());
                            if (comparison != null && !comparison.compare(
                                    feature.getStringProperty(propertyName),
                                    filterCondition.getValueType(),
                                    (String) filterCondition.getValue())) {
                                skipFeature = true;
                                break;
                            }
                        } else {
                            skipFeature = true;
                        }
                    }

                    if (!skipFeature) {
                        filteredFeatures.add(feature);
                    }
                }
            } else {
                filteredFeatures = new ArrayList<>(featuresList);
            }
        }

        return FeatureCollection.fromFeatures(filteredFeatures);
    }

    private  FeatureFilter(@NonNull Builder builder);

}