src/main/java/de/blau/android/presets/PresetItem.java
/**
     * Returns the number of matches between the list of non-optional tags and the provided tags
     * 
     * Uses the match value to control actual behavior
     * 
     * @param tagMap Map containing the tags
     * @return number of matches
     */
Returns the number of matches between the list of non-optional tags and the provided tags

Uses the match value to control actual behavior

@param tagMap Map containing the tags
@return number of matches
Returns the number of matches between the list of non - optional tags and the provided tags Uses the match value to control actual behavior @param tagMap Map containing the tags @return number of matches
int matchesRecommended(@NonNull Map<String, String> tagMap) {
        int matches = 0;
        List<PresetField> allFields = new ArrayList<>();
        for (PresetField field : fields.values()) {
            if (field instanceof PresetCheckGroupField) {
                allFields.addAll(((PresetCheckGroupField) field).getCheckFields());
            } else {
                allFields.add(field);
            }
        }
        for (PresetField field : allFields) { 
            String key = field.getKey();
            if (field.isOptional() || field instanceof PresetFixedField) {
                continue;
            }
            MatchType type = field.matchType;
            if (tagMap.containsKey(key)) { 
                if (type == MatchType.NONE) {
                    continue;
                }
                if (type == MatchType.KEY || type == MatchType.KEY_NEG) {
                    matches++;
                    continue;
                }
                String otherTagValue = tagMap.get(key);
                if (field instanceof PresetComboField && ((PresetComboField) field).getValues() != null) {
                    boolean matched = false;
                    for (StringWithDescription v : ((PresetComboField) field).getValues()) {
                        if (v.equals(otherTagValue)) {
                            matched = true;
                            break;
                        }
                    }
                    if (matched) {
                        matches++;
                    } else if (type == MatchType.KEY_VALUE_NEG) {
                        matches--;
                    }
                } else if (field instanceof PresetCheckField) {
                    String onValue = ((PresetCheckField) field).getOnValue().getValue();
                    String offValue = ((PresetCheckField) field).getOnValue() != null ? ((PresetCheckField) field).getOnValue().getValue() : null;
                    if (otherTagValue.equals(onValue) || otherTagValue.equals(offValue)) {
                        matches++;
                    } else if (type == MatchType.KEY_VALUE_NEG) {
                        matches--;
                    }
                }
            } else {
                if (type == MatchType.KEY_NEG || type == MatchType.KEY_VALUE_NEG) {
                    matches--;
                }
            }
        }
        return matches;
    }
int matchesRecommended ( @ NonNull Map < String , String > tagMap ) { int matches = 0 ; List < PresetField > allFields = new ArrayList < > ( ) ; for ( PresetField field : fields . values ( ) ) { if ( field instanceof PresetCheckGroupField ) { allFields . addAll ( ( ( PresetCheckGroupField ) field ) . getCheckFields ( ) ) ; } else { allFields . add ( field ) ; } } for ( PresetField field : allFields ) { String key = field . getKey ( ) ; if ( field . isOptional ( ) || field instanceof PresetFixedField ) { continue ; } MatchType type = field . matchType ; if ( tagMap . containsKey ( key ) ) { if ( type == MatchType . NONE ) { continue ; } if ( type == MatchType . KEY || type == MatchType . KEY_NEG ) { matches ++ ; continue ; } String otherTagValue = tagMap . get ( key ) ; if ( field instanceof PresetComboField && ( ( PresetComboField ) field ) . getValues ( ) != null ) { boolean matched = false ; for ( StringWithDescription v : ( ( PresetComboField ) field ) . getValues ( ) ) { if ( v . equals ( otherTagValue ) ) { matched = true ; break ; } } if ( matched ) { matches ++ ; } else if ( type == MatchType . KEY_VALUE_NEG ) { matches -- ; } } else if ( field instanceof PresetCheckField ) { String onValue = ( ( PresetCheckField ) field ) . getOnValue ( ) . getValue ( ) ; String offValue = ( ( PresetCheckField ) field ) . getOnValue ( ) != null ? ( ( PresetCheckField ) field ) . getOnValue ( ) . getValue ( ) : null ; if ( otherTagValue . equals ( onValue ) || otherTagValue . equals ( offValue ) ) { matches ++ ; } else if ( type == MatchType . KEY_VALUE_NEG ) { matches -- ; } } } else { if ( type == MatchType . KEY_NEG || type == MatchType . KEY_VALUE_NEG ) { matches -- ; } } } return matches ; }
Returns the number of matches between the list of non-optional tags and the provided tags
Returns the number of matches between the list of non - optional tags and the provided tags
// for each own tag // key could have null value in the set // value not empty // don't count this