src/main/java/de/blau/android/presets/Preset.java
/**
     * Filter a list of elements by type
     * 
     * @param originalElements the list to filter
     * @param type the type to allow
     * @return a filtered list containing only elements of the specified type
     */
Filter a list of elements by type

@param originalElements the list to filter
@param type the type to allow
@return a filtered list containing only elements of the specified type
Filter a list of elements by type @param originalElements the list to filter @param type the type to allow @return a filtered list containing only elements of the specified type
@NonNull
    static List<PresetElement> filterElements(@NonNull List<PresetElement> originalElements, @NonNull ElementType type) {
        List<PresetElement> filteredElements = new ArrayList<>();
        for (PresetElement e : originalElements) {
            if (!e.isDeprecated() && (e.appliesTo(type) || ((e instanceof PresetSeparator) && !filteredElements.isEmpty()
                    && !(filteredElements.get(filteredElements.size() - 1) instanceof PresetSeparator)))) {
                filteredElements.add(e);
            }
        }
        return filteredElements;
    }
@ NonNull static List < PresetElement > filterElements ( @ NonNull List < PresetElement > originalElements , @ NonNull ElementType type ) { List < PresetElement > filteredElements = new ArrayList < > ( ) ; for ( PresetElement e : originalElements ) { if ( ! e . isDeprecated ( ) && ( e . appliesTo ( type ) || ( ( e instanceof PresetSeparator ) && ! filteredElements . isEmpty ( ) && ! ( filteredElements . get ( filteredElements . size ( ) - 1 ) instanceof PresetSeparator ) ) ) ) { filteredElements . add ( e ) ; } } return filteredElements ; }
Filter a list of elements by type
Filter a list of elements by type
// only add separators if there is a non-separator element above them