Skip to content

Switch DataAccess DataStore parameters map values from String to generic object

Nuno Oliveira edited this page Nov 10, 2020 · 6 revisions

Description

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.

Assigned to Release

GeoTools 25

Status

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

Tasks

  1. Update API
  2. Documentation changes
    • Upgrade note upgrading page.
    • Update the user guide with code example

API Change

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;
}
Clone this wiki locally