fix #2691 use ParamMap

This commit is contained in:
Shinsuke Sugaya 2022-10-17 08:00:07 +09:00
parent cee952cb06
commit ff3c294537
3 changed files with 18 additions and 5 deletions

View file

@ -23,11 +23,11 @@ public class DataStoreParams {
protected final Map<String, Object> params;
public DataStoreParams() {
params = new HashMap<>();
params = new ParamMap<>(new HashMap<>());
}
protected DataStoreParams(final Map<String, Object> params) {
this.params = new HashMap<>(params);
this.params = new ParamMap<>(new HashMap<>(getDataMap(params)));
}
public void put(final String key, final Object value) {
@ -70,6 +70,14 @@ public class DataStoreParams {
}
public Map<String, Object> asMap() {
return new HashMap<>(params);
return new ParamMap<>(new HashMap<>(getDataMap(params)));
}
protected static Map<String, Object> getDataMap(final Map<String, Object> params) {
if (params instanceof ParamMap<String, Object> paramMap) {
return paramMap.getParent();
} else {
return params;
}
}
}

View file

@ -13,7 +13,7 @@
* either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/
package org.codelibs.fess.ds;
package org.codelibs.fess.entity;
import java.util.Collection;
import java.util.Map;
@ -34,6 +34,10 @@ public class ParamMap<K, V> implements Map<K, V> {
this.parent = parent;
}
public Map<K, V> getParent() {
return parent;
}
protected Object toCamelCase(final Object key) {
if (key == null) {
return key;

View file

@ -13,11 +13,12 @@
* either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/
package org.codelibs.fess.ds;
package org.codelibs.fess.entity;
import java.util.HashMap;
import java.util.Map;
import org.codelibs.fess.entity.ParamMap;
import org.codelibs.fess.unit.UnitFessTestCase;
public class ParamMapTest extends UnitFessTestCase {