Changeset 16358 in josm


Ignore:
Timestamp:
2020-04-19T14:54:59+02:00 (5 years ago)
Author:
simon04
Message:

see #18164 - Rename class to SearchCompilerQueryWizard

Location:
trunk
Files:
3 edited
2 moved

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/MainInitialization.java

    r16321 r16358  
    88import java.util.Arrays;
    99import java.util.Collection;
     10import java.util.Collections;
    1011import java.util.List;
    1112import java.util.Objects;
     
    3738import org.openstreetmap.josm.tools.Logging;
    3839import org.openstreetmap.josm.tools.OpenBrowser;
    39 import org.openstreetmap.josm.tools.OverpassTurboQueryWizard;
    4040import org.openstreetmap.josm.tools.PlatformManager;
    4141import org.openstreetmap.josm.tools.Shortcut;
     
    127127    @Override
    128128    public List<Callable<?>> asynchronousCallableTasks() {
    129         return Arrays.asList(
    130                 OverpassTurboQueryWizard::getInstance
    131             );
     129        return Collections.emptyList();
    132130    }
    133131
  • trunk/src/org/openstreetmap/josm/gui/download/OverpassQueryWizardDialog.java

    r16355 r16358  
    1616import org.openstreetmap.josm.gui.download.overpass.OverpassWizardRegistration.OverpassWizardCallbacks;
    1717import org.openstreetmap.josm.tools.Logging;
    18 import org.openstreetmap.josm.tools.OverpassTurboQueryWizard;
     18import org.openstreetmap.josm.tools.SearchCompilerQueryWizard;
    1919import org.openstreetmap.josm.tools.UncheckedParseException;
    2020import org.openstreetmap.josm.tools.Utils;
     
    8282
    8383    /**
    84      * Tries to process a search term using {@link OverpassTurboQueryWizard}. If the term cannot
     84     * Tries to process a search term using {@link SearchCompilerQueryWizard}. If the term cannot
    8585     * be parsed, the the corresponding dialog is shown.
    8686     * @param searchTerm The search term to parse.
     
    9191    private Optional<String> tryParseSearchTerm(String searchTerm) {
    9292        try {
    93             return Optional.of(OverpassTurboQueryWizard.getInstance().constructQuery(searchTerm));
     93            return Optional.of(SearchCompilerQueryWizard.getInstance().constructQuery(searchTerm));
    9494        } catch (UncheckedParseException | IllegalStateException ex) {
    9595            Logging.error(ex);
  • trunk/src/org/openstreetmap/josm/tools/SearchCompilerQueryWizard.java

    r16357 r16358  
    2424 * @since 8744 (using tyrasd/overpass-wizard), 16262 (standalone)
    2525 */
    26 public final class OverpassTurboQueryWizard {
    27 
    28     private static final OverpassTurboQueryWizard instance = new OverpassTurboQueryWizard();
     26public final class SearchCompilerQueryWizard {
     27
     28    private static final SearchCompilerQueryWizard instance = new SearchCompilerQueryWizard();
    2929
    3030    /**
     
    3333     * @return the unique instance of this class
    3434     */
    35     public static OverpassTurboQueryWizard getInstance() {
     35    public static SearchCompilerQueryWizard getInstance() {
    3636        return instance;
    3737    }
    3838
    39     private OverpassTurboQueryWizard() {
     39    private SearchCompilerQueryWizard() {
    4040        // private constructor for utility class
    4141    }
     
    182182    private static List<Match> normalizeToDNF(final Match match) {
    183183        if (match instanceof SearchCompiler.And) {
    184             return ((SearchCompiler.And) match).map(OverpassTurboQueryWizard::normalizeToDNF, (lhs, rhs) -> lhs.stream()
     184            return ((SearchCompiler.And) match).map(SearchCompilerQueryWizard::normalizeToDNF, (lhs, rhs) -> lhs.stream()
    185185                    .flatMap(l -> rhs.stream().map(r -> new SearchCompiler.And(l, r)))
    186186                    .collect(Collectors.toList()));
    187187        } else if (match instanceof SearchCompiler.Or) {
    188             return ((SearchCompiler.Or) match).map(OverpassTurboQueryWizard::normalizeToDNF, CompositeList::new);
     188            return ((SearchCompiler.Or) match).map(SearchCompilerQueryWizard::normalizeToDNF, CompositeList::new);
    189189        } else if (match instanceof SearchCompiler.Xor) {
    190190            throw new UnsupportedOperationException(match.toString());
  • trunk/test/unit/org/openstreetmap/josm/io/OverpassDownloadReaderTest.java

    r15821 r16358  
    2222import org.openstreetmap.josm.io.OverpassDownloadReader.OverpassOutpoutFormat;
    2323import org.openstreetmap.josm.testutils.JOSMTestRules;
    24 import org.openstreetmap.josm.tools.OverpassTurboQueryWizard;
     24import org.openstreetmap.josm.tools.SearchCompilerQueryWizard;
    2525import org.openstreetmap.josm.tools.Utils;
    2626import org.openstreetmap.josm.tools.date.DateUtils;
     
    5959
    6060    private String getExpandedQuery(String search) {
    61         final String query = OverpassTurboQueryWizard.getInstance().constructQuery(search);
     61        final String query = SearchCompilerQueryWizard.getInstance().constructQuery(search);
    6262        final String request = new OverpassDownloadReader(new Bounds(1, 2, 3, 4), null, query)
    6363                .getRequestForBbox(1, 2, 3, 4)
  • trunk/test/unit/org/openstreetmap/josm/tools/SearchCompilerQueryWizardTest.java

    r16357 r16358  
    1212
    1313/**
    14  * Unit tests of {@link OverpassTurboQueryWizard} class.
     14 * Unit tests of {@link SearchCompilerQueryWizard} class.
    1515 */
    16 public class OverpassTurboQueryWizardTest {
     16public class SearchCompilerQueryWizardTest {
    1717    /**
    1818     * Base test environment is enough
     
    2222    public JOSMTestRules test = new JOSMTestRules().i18n("de");
    2323
     24    private static String constructQuery(String s) {
     25        return SearchCompilerQueryWizard.getInstance().constructQuery(s);
     26    }
     27
    2428    private void assertQueryEquals(String expectedQueryPart, String input) {
    25         final String query = OverpassTurboQueryWizard.getInstance().constructQuery(input);
     29        final String query = constructQuery(input);
    2630        assertEquals("" +
    2731                "[out:xml][timeout:90][bbox:{{bbox}}];\n" +
     
    139143    @Test
    140144    public void testInArea() {
    141         String query = OverpassTurboQueryWizard.getInstance().constructQuery("foo=bar | foo=baz in Innsbruck");
     145        String query = constructQuery("foo=bar | foo=baz in Innsbruck");
    142146        assertEquals("" +
    143147                "[out:xml][timeout:90];\n" +
     
    149153                "(._;>;);\n" +
    150154                "out meta;", query);
    151         query = OverpassTurboQueryWizard.getInstance().constructQuery("foo=bar | foo=baz in \"Sankt Sigmund im Sellrain\"");
     155        query = constructQuery("foo=bar | foo=baz in \"Sankt Sigmund im Sellrain\"");
    152156        assertEquals("" +
    153157                "[out:xml][timeout:90];\n" +
     
    159163                "(._;>;);\n" +
    160164                "out meta;", query);
    161         query = OverpassTurboQueryWizard.getInstance().constructQuery("foo=bar | foo=baz in \"Новосибирск\"");
     165        query = constructQuery("foo=bar | foo=baz in \"Новосибирск\"");
    162166        assertEquals("" +
    163167                "[out:xml][timeout:90];\n" +
     
    176180    @Test
    177181    public void testAroundArea() {
    178         final String query = OverpassTurboQueryWizard.getInstance().constructQuery("foo=bar | foo=baz around \"Sankt Sigmund im Sellrain\"");
     182        final String query = constructQuery("foo=bar | foo=baz around \"Sankt Sigmund im Sellrain\"");
    179183        assertEquals("" +
    180184                "[out:xml][timeout:90];\n" +
     
    193197    @Test
    194198    public void testGlobal() {
    195         final String query = OverpassTurboQueryWizard.getInstance().constructQuery("foo=bar global");
     199        final String query = constructQuery("foo=bar global");
    196200        assertEquals("" +
    197201                "[out:xml][timeout:90];\n" +
     
    225229    @Test(expected = UncheckedParseException.class)
    226230    public void testErroneous() {
    227         OverpassTurboQueryWizard.getInstance().constructQuery("-(foo or bar)");
     231        constructQuery("-(foo or bar)");
    228232    }
    229233}
Note: See TracChangeset for help on using the changeset viewer.