Browse Source

Simplify DisplayLocation a bit.

pull/777/head
Shane Mc Cormack 7 years ago
parent
commit
826eeb5bd3

+ 4
- 23
api/src/main/java/com/dmdirc/events/DisplayLocation.java View File

@@ -29,14 +29,15 @@ import java.util.function.BiPredicate;
29 29
 /**
30 30
  * Valid values for the DISPLAY_LOCATION property and how to test for them.
31 31
  */
32
+@FunctionalInterface
32 33
 public interface DisplayLocation {
33 34
     /** Event came from the same WindowModel. */
34
-    DisplayLocation SOURCE = new DisplayLocationImpl((model, event) -> event.getSource().equals(model));
35
+    DisplayLocation SOURCE = (model, event) -> event.getSource().equals(model);
35 36
 
36 37
     /** Event came from a WindowModel that shares the same connection. */
37
-    DisplayLocation SAME_CONNECTION = new DisplayLocationImpl((model, event) -> event.getSource().getConnection().isPresent()
38
+    DisplayLocation SAME_CONNECTION = (model, event) -> event.getSource().getConnection().isPresent()
38 39
             && model.getConnection().isPresent()
39
-            && event.getSource().getConnection().get().equals(model.getConnection().get()));
40
+            && event.getSource().getConnection().get().equals(model.getConnection().get());
40 41
     /**
41 42
      * Test to see if this location is valid.
42 43
      *
@@ -45,24 +46,4 @@ public interface DisplayLocation {
45 46
      * @return True if the event should be displayed here.
46 47
      */
47 48
     boolean shouldDisplay(final WindowModel model, final DisplayableEvent event);
48
-
49
-    final class DisplayLocationImpl implements DisplayLocation {
50
-        /**
51
-         * Function to test this DisplayLocation.
52
-         */
53
-        private BiPredicate<WindowModel, DisplayableEvent> locationTester;
54
-
55
-        /**
56
-         * Create a new DisplayLocation
57
-         *
58
-         * @param test Test function to run to see if this location is valid.
59
-         */
60
-        DisplayLocationImpl(final BiPredicate<WindowModel, DisplayableEvent> test) {
61
-            locationTester = test;
62
-        }
63
-
64
-        public boolean shouldDisplay(final WindowModel model, final DisplayableEvent event) {
65
-            return locationTester.test(model, event);
66
-        }
67
-    }
68 49
 };

+ 1
- 1
src/main/java/com/dmdirc/ui/messages/DisplayLocationManager.java View File

@@ -28,7 +28,7 @@ import java.util.Set;
28 28
 
29 29
 @Singleton
30 30
 public class DisplayLocationManager {
31
-    public Map<String, DisplayLocation> displayLocations = new HashMap<>();
31
+    private final Map<String, DisplayLocation> displayLocations = new HashMap<>();
32 32
 
33 33
     @Inject
34 34
     DisplayLocationManager() {

+ 1
- 1
src/main/java/com/dmdirc/ui/messages/YamlEventFormatProvider.java View File

@@ -131,7 +131,7 @@ public class YamlEventFormatProvider implements EventFormatProvider {
131 131
             } catch (final IllegalArgumentException iae) {
132 132
                 LOG.info(USER_ERROR, "Invalid displaywindow specified for: {}.\nValid values are: {}",
133 133
                         info.get("displaywindow").toString(),
134
-                        Arrays.toString(displayLocationManager.getDisplayLocations().toArray()));
134
+                        displayLocationManager.getDisplayLocations().toString());
135 135
             }
136 136
         }
137 137
         return map;

Loading…
Cancel
Save