Opened 10 years ago
Last modified 10 years ago
#12885 closed enhancement
Modify OsmValidator class to add new tests — at Version 1
| Reported by: | darya | Owned by: | team |
|---|---|---|---|
| Priority: | normal | Milestone: | 16.05 |
| Component: | Core validator | Version: | |
| Keywords: | OsmValidator, GSoC | Cc: | darya |
Description (last modified by )
I'm creating a JOSM plugin to validate public transport routes. I want the results to appear in the existing Validator window. To do that, I need the possibility to add additional Test classes to the org.openstreetmap.josm.data.validation.OsmValidator class.
A possible fix for my needs would be:
1) Change the class attribute private static final allAvailableTests to private static allAvailableTests
2) Add method:
public static void addTest(Class newTestClass) { Class<Test>[] newTestArray = new Class[allAvailableTests.length+1]; for (int i=0; i<allAvailableTests.length; i++) { newTestArray[i] = allAvailableTests[i]; } newTestArray[newTestArray.length-1] = newTestClass; allAvailableTests = newTestArray; try { allTestsMap.put(newTestClass.getName(), (Test)newTestClass.getConstructor().newInstance()); } catch(ReflectiveOperationException e) { Main.error(e); } }
An alternative solution would be to change the method OsmValidator.getAllTestsMap()
from
public static SortedMap<String, Test> getAllTestsMap() { applyPrefs(allTestsMap, false); return new TreeMap<>(allTestsMap); }
to
public static SortedMap<String, Test> getAllTestsMap() { applyPrefs(allTestsMap, false); TreeMap<String, Test> sortedMap = new TreeMap<>(allTestsMap); allTestsMap = sortedMap; return sortedMap; }
Thank you in advance!


