Switch DataAccess DataStore parameters map values from String to generic object
- Contact: Andrea Aime
- Tracker: https://osgeo-org.atlassian.net/browse/GEOT-6728
- TLDR: Adapt store creation interfaces to actual usage
- Branch: https://github.com/aaime/geotools/tree/store_parameter_map
- PR: https://github.com/geotools/geotools/pull/3195
The current API for DataAccess
and DataStore
creation requires providing a Map<String, Serializable>
, e.g., from DataAccessFactory
:
DataAccess<? extends FeatureType, ? extends Feature> createDataStore(
Map<String, Serializable> params) throws IOException;
In practice, DataStore implementations started requiring non Serializable objects as parameters, for example,
Repository
implementations, which are typically hard to conceive as serializable.
The system so far worked because most implementatations actually use raw Map
object, hiding the mismatch between
required API and practical usage.
This proposal switches the relevant factory API bits to use Map<String, ?>
instead, allowing any type of key to be used.
Using ?
instead of Object
allows to preserve most client code un-modified, as any type of actual parameter can be used
for the second generic, while forcing a Map<String, Object>
would have broken existing clients building and providing a
Map<String, Serializable>
.
As proof of that, the existing documentation, using DataStoreFinder
with a variety of Map implementatations and generics (String to Serializable, String to String, String to Object), did not need to be modified to build under the updated API.
Regardless of this, the API switch is going to break DataAcessFactory
and DataStoreFactory
implementations using the
previous generics.
GeoTools 25
Choose one of:
- Under Discussion
- In Progress
- Completed
- Rejected,
- Deferred
Voting:
- Andrea Aime: +1
- Ian Turton: +1
- Jody Garnett: +1
- Nuno Oliveira: +1
- Simone Giannecchini: +1
- Torben Barsballe: +1
- Update API
- Documentation changes
- Upgrade note upgrading page.
- Update the user guide with code example
Before:
public interface DataAccessFactory {
DataAccess<? extends FeatureType, ? extends Feature> createDataStore(
Map<String, Serializable> params) throws IOException;
}
After:
public interface DataAccessFactory {
DataAccess<? extends FeatureType, ? extends Feature> createDataStore(
Map<String, ?> params) throws IOException;
}