|
@@ -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
|
};
|