Changeset 16269 in josm for trunk


Ignore:
Timestamp:
2020-04-12T14:55:05+02:00 (4 years ago)
Author:
simon04
Message:

Extract TagInfoExtract.TagInfoTag.Type#forPresetType

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/scripts/TagInfoExtract.java

    r16234 r16269  
    268268                            : Collections.emptyList();
    269269                    for (String value : values) {
    270                         final Set<TagInfoTag.Type> types = preset.types == null ? Collections.emptySet() : preset.types.stream()
    271                                 .map(it -> TaggingPresetType.CLOSEDWAY.equals(it)
    272                                         ? TagInfoTag.Type.AREA
    273                                         : TaggingPresetType.MULTIPOLYGON.equals(it)
    274                                         ? TagInfoTag.Type.RELATION
    275                                         : TagInfoTag.Type.valueOf(it.toString()))
    276                                 .collect(Collectors.toCollection(() -> EnumSet.noneOf(TagInfoTag.Type.class)));
     270                        final Set<TagInfoTag.Type> types = TagInfoTag.Type.forPresetTypes(preset.types);
    277271                        tags.add(new TagInfoTag(descriptionPrefix + preset.getName(), item.key, value, types,
    278272                                addImages && preset.iconName != null ? options.findImageUrl(preset.iconName) : null));
     
    563557
    564558        enum Type {
    565             NODE, WAY, AREA, RELATION
     559            NODE, WAY, AREA, RELATION;
     560
     561            static TagInfoTag.Type forPresetType(TaggingPresetType type) {
     562                switch (type) {
     563                    case CLOSEDWAY:
     564                        return AREA;
     565                    case MULTIPOLYGON:
     566                        return RELATION;
     567                    default:
     568                        return valueOf(type.toString());
     569                }
     570            }
     571
     572            static Set<TagInfoTag.Type> forPresetTypes(Set<TaggingPresetType> types) {
     573                if (types == null) {
     574                    return Collections.emptySet();
     575                }
     576                return types.stream()
     577                        .map(Type::forPresetType)
     578                        .collect(Collectors.toCollection(() -> EnumSet.noneOf(Type.class)));
     579            }
    566580        }
    567581    }
Note: See TracChangeset for help on using the changeset viewer.