2 * DemosceneMusic - Properties.java - Copyright © 2012 David Roden
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 package net.pterodactylus.demoscenemusic.data;
20 import java.util.HashMap;
21 import java.util.Iterator;
23 import java.util.Map.Entry;
26 * Container for custom properties that can be attached to all data containers.
28 * @see Base#getProperties()
29 * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
31 public class Properties implements Iterable<Entry<String, String>> {
33 /** The properties. */
34 private final Map<String, String> properties = new HashMap<String, String>();
41 * Returns the value of the property with the given name.
44 * The name of the property
45 * @return The value of the property, or {@code null} if the property with
46 * the given name does not exist
48 public String get(String property) {
49 return properties.get(property);
53 * Sets the value of the property with the given name.
56 * The name of the property
58 * The new value of the property
59 * @return These properties
61 public Properties set(String property, String value) {
62 properties.put(property, value);
67 * Removes the property with the given name.
70 * The name of the property
71 * @return These properties
73 public Properties remove(String property) {
74 properties.remove(property);
79 * Removes all properties.
81 * @return These properties
83 public Properties removeAll() {
96 public Iterator<Entry<String, String>> iterator() {
97 return properties.entrySet().iterator();