001    /*
002     @license.text@ 
003     */
004    package biz.hammurapi.properties;
005    
006    import java.util.Set;
007    
008    import biz.hammurapi.config.MutableContext;
009    
010    /**
011     * Set of properties
012     * @author Pavel
013     *
014     * @param <V> Value type.
015     */
016    public interface PropertySet extends MutableContext {
017            
018            /**
019             * @return Names of properties in the set
020             */
021            Set getPropertyNames();
022            
023            /**
024             * @param prefix
025             * @return Property set which operates on properties starting with given prefix.
026             */
027            PropertySet getSubset(String prefix);
028            
029            /**
030             * Removes property from the set.
031             * @param name
032             */
033            boolean remove(String name);
034            
035            /**
036             * Removes all entries from the property set
037             */
038            void clear();
039            
040            /**
041             * Mounts source property set at specified prefix. E.g. if source property set has entry 'a' and prefix is 'b/' then that entry will be 
042             * available as 'b/a'. Own property set entries shall shadow mounted entries.
043             * @param prefix
044             * @param source
045             */
046            void mount(String prefix, PropertySet source);
047            
048            /**
049             * Copies all entries from the source property set to self.
050             * @param source
051             */
052            void setAll(PropertySet source);        
053            
054            /**
055             * @param subSet
056             * @return true if all properties of subset are present in this set with same values
057             */
058            boolean containsAll(PropertySet subSet);
059            
060            /**
061             * @param otherSet
062             * @return true if all properties in this set are equal to properties in the other set.
063             */
064            boolean compareProperties(PropertySet otherSet);
065            
066            /**
067             * Retrieves property.
068             */
069            public Object get(String name);
070            
071            /**
072             * @param name Property name.
073             * @param defaultValue Default value.
074             * @return Property value or default value if property doesn't exist in the
075             * property set.
076             */
077            public Object get(String name, Object defaultValue);
078            
079            /**
080             * Sets property.
081             * @param name
082             * @param value
083             */
084            public void set(String name, Object value);
085    }