@@ -0,0 +1,2942 @@
+package org.jtheque.states.utils;%0A%0A/*%0A * Copyright JTheque (Baptiste Wicht)%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A * http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0A%0Aimport org.jtheque.states.able.Load;%0Aimport org.jtheque.states.able.Save;%0Aimport org.jtheque.utils.annotations.ThreadSafe;%0Aimport org.jtheque.utils.collections.CollectionUtils;%0A%0Aimport java.util.Map;%0A%0A/**%0A * An abstract state. This state is not delegated and manage a simple map of properties. This class is thread safe.%0A *%0A * @author Baptiste Wicht%0A */%0A@ThreadSafe%0Apublic abstract class AbstractConcurrentState %7B%0A    private final Map%3CString, String%3E properties = CollectionUtils.newConcurrentMap(10);%0A%0A    /**%0A     * Set the properties of this state. This method is made to be called from the state service. It will be called only%0A     * once, at startup.%0A     *%0A     * @param properties The properties of this state.%0A     */%0A    @Load%0A    public void setProperties(Map%3CString, String%3E properties) %7B%0A        this.properties.putAll(properties);%0A    %7D%0A%0A    /**%0A     * Return all the properties of the state. This method is made to be called from the state service. It will be%0A     * called only once, at application shutdown.%0A     *%0A     * @return The properties of the state.%0A     */%0A    @Save%0A    public Map%3CString, String%3E getProperties() %7B%0A        return CollectionUtils.protect(properties);%0A    %7D%0A%0A    /**%0A     * Return the value of a property.%0A     *%0A     * @param key The key of the property.%0A     *%0A     * @return The value of the property with the given key or null if the property doesn't exist.%0A     */%0A    protected final String getProperty(String key) %7B%0A        return properties.get(key);%0A    %7D%0A%0A    /**%0A     * Return the value of a property.%0A     *%0A     * @param key      The key of the property.%0A     * @param defaults The default value to use if the property doesn't exist.%0A     *%0A     * @return The value of the property with the given key or the given default value if the property doesn't exist.%0A     */%0A    protected final String getProperty(String key, String defaults) %7B%0A        if (properties.containsKey(key)) %7B%0A            return properties.get(key);%0A        %7D else %7B%0A            return defaults;%0A        %7D%0A    %7D%0A%0A    /**%0A     * Set the property value of the state.%0A     *%0A     * @param key   The key of the property.%0A     * @param value The value of the property.%0A     */%0A    protected final void setProperty(String key, String value) %7B%0A        properties.put(key, value);%0A    %7D%0A%7D

Provide a thread safe abstract state