| Class | Line # | Actions | |||||
|---|---|---|---|---|---|---|---|
| WikiPropertyGroup | 32 | 11 | 0% | 6 | 1 |
| 1 | /* | |
| 2 | * See the NOTICE file distributed with this work for additional | |
| 3 | * information regarding copyright ownership. | |
| 4 | * | |
| 5 | * This is free software; you can redistribute it and/or modify it | |
| 6 | * under the terms of the GNU Lesser General Public License as | |
| 7 | * published by the Free Software Foundation; either version 2.1 of | |
| 8 | * the License, or (at your option) any later version. | |
| 9 | * | |
| 10 | * This software is distributed in the hope that it will be useful, | |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 13 | * Lesser General Public License for more details. | |
| 14 | * | |
| 15 | * You should have received a copy of the GNU Lesser General Public | |
| 16 | * License along with this software; if not, write to the Free | |
| 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | |
| 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. | |
| 19 | */ | |
| 20 | package org.xwiki.wiki.properties; | |
| 21 | ||
| 22 | import java.util.HashMap; | |
| 23 | import java.util.Map; | |
| 24 | ||
| 25 | /** | |
| 26 | * Property group is a place where modules can store their own properties concerning a wiki. This group is then attached | |
| 27 | * to the WikiDescriptor. Each module is responsible for the persistent storage of its properties. | |
| 28 | * | |
| 29 | * @version $Id: 1ecfc5cf5e9d018beaab3907e1a237e600d8df42 $ | |
| 30 | * @since 5.3M2 | |
| 31 | */ | |
| 32 | public class WikiPropertyGroup implements Cloneable | |
| 33 | { | |
| 34 | /** | |
| 35 | * Unique identifier of the property group. | |
| 36 | */ | |
| 37 | private String id; | |
| 38 | ||
| 39 | /** | |
| 40 | * Properties. | |
| 41 | */ | |
| 42 | private Map<String, Object> properties; | |
| 43 | ||
| 44 | /** | |
| 45 | * Constructor. | |
| 46 | * | |
| 47 | * @param id Unique identifier of the group | |
| 48 | */ | |
| 49 | 21 | public WikiPropertyGroup(String id) |
| 50 | { | |
| 51 | 21 | this.id = id; |
| 52 | 21 | this.properties = new HashMap<String, Object>(); |
| 53 | } | |
| 54 | ||
| 55 | /** | |
| 56 | * @return the unique identifier of the group | |
| 57 | */ | |
| 58 | 4051 | public String getId() |
| 59 | { | |
| 60 | 4052 | return id; |
| 61 | } | |
| 62 | ||
| 63 | /** | |
| 64 | * Get the value of a property. | |
| 65 | * | |
| 66 | * @param propertyId Id of the property | |
| 67 | * @return the value of the property | |
| 68 | */ | |
| 69 | 15 | public Object get(String propertyId) |
| 70 | { | |
| 71 | 15 | return properties.get(propertyId); |
| 72 | } | |
| 73 | ||
| 74 | /** | |
| 75 | * Set the value of a property. | |
| 76 | * | |
| 77 | * @param propertyId Id of the property to change | |
| 78 | * @param value value so store in the property | |
| 79 | */ | |
| 80 | 36 | public void set(String propertyId, Object value) |
| 81 | { | |
| 82 | 36 | properties.put(propertyId, value); |
| 83 | } | |
| 84 | ||
| 85 | 4034 | @Override |
| 86 | public WikiPropertyGroup clone() | |
| 87 | { | |
| 88 | 4037 | WikiPropertyGroup group; |
| 89 | 4034 | try { |
| 90 | 4036 | group = (WikiPropertyGroup) super.clone(); |
| 91 | } catch (CloneNotSupportedException e) { | |
| 92 | // Supposed to be impossible | |
| 93 | 0 | return new WikiPropertyGroup(getId()); |
| 94 | } | |
| 95 | ||
| 96 | // Clone the map | |
| 97 | 4035 | group.properties = new HashMap<>(this.properties); |
| 98 | ||
| 99 | 4034 | return group; |
| 100 | } | |
| 101 | } |