All Downloads are FREE. Search and download functionalities are using the official Maven repository.

fr.ird.observe.spi.map.MutableDtoMap Maven / Gradle / Ivy

There is a newer version: 4.34
Show newest version
package fr.ird.observe.spi.map;

/*-
 * #%L
 * ObServe Toolkit :: Common Dto
 * %%
 * Copyright (C) 2017 - 2020 IRD, Ultreia.io
 * %%
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public
 * License along with this program.  If not, see
 * .
 * #L%
 */

import fr.ird.observe.spi.type.TypeTranslators;

import java.util.Collection;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;

/**
 * A special map to store string values using the {@link #key0(Class)} method to produce keys.
 * 

* Created by tchemit on 01/09/17. * * @author Tony Chemit - [email protected] */ public class MutableDtoMap { private final Map data; public static MutableDtoMap create() { return new MutableDtoMap<>(); } protected MutableDtoMap(MutableDtoMap dtoMap) { this.data = dtoMap.data; } private MutableDtoMap() { this.data = new TreeMap<>(); } public int size() { return data.size(); } public boolean isEmpty() { return data.isEmpty(); } public V get(Class key) { return data.get(key0(key)); } public Set keySet() { return data.keySet(); } public Collection values() { return data.values(); } public void put(Class type, V value) { data.put(key0(type), value); } public void clear() { data.clear(); } private static String key0(Class type) { return TypeTranslators.getTranslator(type).cleanType(type); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy