|
@@ -0,0 +1,77 @@
|
|
1
|
+/*
|
|
2
|
+ * Copyright (c) 2006-2016 DMDirc Developers
|
|
3
|
+ *
|
|
4
|
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
|
|
5
|
+ * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
|
|
6
|
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
|
|
7
|
+ * permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
8
|
+ *
|
|
9
|
+ * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
|
|
10
|
+ * Software.
|
|
11
|
+ *
|
|
12
|
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
|
13
|
+ * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
|
|
14
|
+ * OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
15
|
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
16
|
+ */
|
|
17
|
+
|
|
18
|
+package com.dmdirc.interfaces;
|
|
19
|
+
|
|
20
|
+import com.dmdirc.events.DisplayProperty;
|
|
21
|
+import com.dmdirc.events.DisplayPropertyMap;
|
|
22
|
+import java.util.Optional;
|
|
23
|
+
|
|
24
|
+/**
|
|
25
|
+ * Common interface for objects which may be displayed, and are affected by {@link DisplayProperty}s.
|
|
26
|
+ */
|
|
27
|
+public interface Displayable {
|
|
28
|
+
|
|
29
|
+ /**
|
|
30
|
+ * Retrieves a property relating to how this object should be displayed.
|
|
31
|
+ *
|
|
32
|
+ * @param property The property to be retrieved.
|
|
33
|
+ * @param <T> The type of value that the property takes.
|
|
34
|
+ * @return An optional value for the property.
|
|
35
|
+ */
|
|
36
|
+ <T> Optional<T> getDisplayProperty(DisplayProperty<T> property);
|
|
37
|
+
|
|
38
|
+ /**
|
|
39
|
+ * Sets a property relating to how this object should be displayed.
|
|
40
|
+ *
|
|
41
|
+ * @param property The property to be set
|
|
42
|
+ * @param value The value of the property
|
|
43
|
+ * @param <T> The type of value that the property takes.
|
|
44
|
+ */
|
|
45
|
+ <T> void setDisplayProperty(DisplayProperty<T> property, T value);
|
|
46
|
+
|
|
47
|
+ /**
|
|
48
|
+ * Determines whether this object has a display property.
|
|
49
|
+ *
|
|
50
|
+ * <p>Only use this method if the value of the property does not matter; otherwise use
|
|
51
|
+ * {@link #getDisplayProperty(DisplayProperty)} and use the appropriate {@link Optional}
|
|
52
|
+ * accessors.
|
|
53
|
+ *
|
|
54
|
+ * @param property The property to be checked.
|
|
55
|
+ * @return True if the property is present, false otherwise.
|
|
56
|
+ */
|
|
57
|
+ default boolean hasDisplayProperty(final DisplayProperty<?> property) {
|
|
58
|
+ return getDisplayProperty(property).isPresent();
|
|
59
|
+ }
|
|
60
|
+
|
|
61
|
+ /**
|
|
62
|
+ * Removes a property relating to how this object should be displayed.
|
|
63
|
+ *
|
|
64
|
+ * @param property The property to be removed
|
|
65
|
+ */
|
|
66
|
+ default <T> void removeDisplayProperty(final DisplayProperty<T> property) {
|
|
67
|
+ getDisplayProperties().remove(property);
|
|
68
|
+ }
|
|
69
|
+
|
|
70
|
+ /**
|
|
71
|
+ * Gets the map of all display properties.
|
|
72
|
+ *
|
|
73
|
+ * @return The map of display properties.
|
|
74
|
+ */
|
|
75
|
+ DisplayPropertyMap getDisplayProperties();
|
|
76
|
+
|
|
77
|
+}
|