001// License: GPL. For details, see LICENSE file. 002package org.openstreetmap.josm.data.osm.search; 003 004/** 005 * Search mode. 006 * @since 12659 (extracted from {@code SearchAction}) 007 */ 008public enum SearchMode { 009 /** replace selection */ 010 replace('R'), 011 /** add to selection */ 012 add('A'), 013 /** remove from selection */ 014 remove('D'), 015 /** find in selection */ 016 in_selection('S'); 017 018 private final char code; 019 020 SearchMode(char code) { 021 this.code = code; 022 } 023 024 /** 025 * Returns the unique character code of this mode. 026 * @return the unique character code of this mode 027 */ 028 public char getCode() { 029 return code; 030 } 031 032 /** 033 * Returns the search mode matching the given character code. 034 * @param code character code 035 * @return search mode matching the given character code 036 */ 037 public static SearchMode fromCode(char code) { 038 for (SearchMode mode: values()) { 039 if (mode.getCode() == code) 040 return mode; 041 } 042 return null; 043 } 044}