Skip to content

Package: ECPProperties

ECPProperties

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2013 EclipseSource Muenchen GmbH and others.
3: *
4: * All rights reserved. This program and the accompanying materials
5: * are made available under the terms of the Eclipse Public License 2.0
6: * which accompanies this distribution, and is available at
7: * https://www.eclipse.org/legal/epl-2.0/
8: *
9: * SPDX-License-Identifier: EPL-2.0
10: *
11: * Contributors:
12: * Eike Stepper - initial API and implementation
13: * Eugen Neufeld - JavaDoc
14: *
15: *******************************************************************************/
16: package org.eclipse.emf.ecp.core.util;
17:
18: import java.util.Collection;
19: import java.util.Map;
20: import java.util.Set;
21:
22: import org.eclipse.emf.ecp.core.util.observer.ECPPropertiesObserver;
23:
24: /**
25: * {@link ECPProperties} are used to store key - value - pairs.
26: *
27: * It publishes observable events on the {@link org.eclipse.emf.ecp.core.util.observer.ECPObserverBus ECPObserverBus}.
28: * Related Observer types: {@link ECPPropertiesObserver}. Use {@link ECPUtil#getECPObserverBus()} to
29: * retrieve the ObserverBus and
30: * {@link org.eclipse.emf.ecp.core.util.observer.ECPObserverBus#register(org.eclipse.emf.ecp.core.util.observer.ECPObserver)
31: * ECPObserverBus#register(ECPObserver)} to register an Observer.
32: *
33: * @author Eike Stepper
34: * @author Eugen Neufeld
35: * @noextend This interface is not intended to be extended by clients.
36: * @noimplement This interface is not intended to be implemented by clients.
37: */
38: public interface ECPProperties {
39:         /**
40:          * Adds a key-value-pair.
41:          *
42:          * @param key the key of the property
43:          * @param value the value of the property
44:          */
45:         void addProperty(String key, String value);
46:
47:         /**
48:          * Removes a property.
49:          *
50:          * @param key of the property to remove
51:          */
52:         void removeProperty(String key);
53:
54:         /**
55:          * Get the value of a property identified by this key.
56:          *
57:          * @param key the key of the property to find
58:          * @return the value of the property identified by the key or null
59:          */
60:         String getValue(String key);
61:
62:         /**
63:          * All stored keys.
64:          *
65:          * @return an array of all keys
66:          */
67:         Set<String> getKeys();
68:
69:         /**
70:          * All Properties.
71:          *
72:          * @return an array of Key-Value-Pairs
73:          */
74:         Collection<Map.Entry<String, String>> getProperties();
75:
76:         /**
77:          * Whether any properties are stored.
78:          *
79:          * @return true if at least 1 property was added, false otherwise
80:          */
81:         boolean hasProperties();
82:
83:         /**
84:          * Creates a copy of the current set of properties.
85:          *
86:          * @return the copy of the current properties
87:          */
88:
89:         ECPProperties copy();
90:
91:         /**
92:          * Adds an {@link ECPPropertiesObserver} which will be notified if a property changes.
93:          *
94:          * @param changeObserver the observer to add
95:          */
96:         void addObserver(ECPPropertiesObserver changeObserver);
97:
98:         /**
99:          * Removes an {@link ECPPropertiesObserver} from the collection of observer which will be notified if a
100:          * property changes.
101:          *
102:          * @param changeObserver the observer to remove
103:          */
104:         void removeObserver(ECPPropertiesObserver changeObserver);
105:
106: }