Skip to content

Commit f009977

Browse files
committed
Display: move default method impls to iface
1 parent d287bc9 commit f009977

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

src/main/java/org/scijava/display/AbstractDisplay.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,6 @@ public boolean canDisplay(final Class<?> c) {
109109
return type.isAssignableFrom(c);
110110
}
111111

112-
@Override
113-
public boolean canDisplay(final Object o) {
114-
if (o == null) return false;
115-
return canDisplay(o.getClass());
116-
}
117-
118112
@Override
119113
public void display(final Object o) {
120114
checkObject(o);
@@ -123,11 +117,6 @@ public void display(final Object o) {
123117
add(typedObj);
124118
}
125119

126-
@Override
127-
public boolean isDisplaying(final Object o) {
128-
return contains(o);
129-
}
130-
131120
@Override
132121
public void update() {
133122
if (eventService != null && !isClosed) {

src/main/java/org/scijava/display/Display.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,10 @@ public interface Display<T> extends List<T>, RichPlugin, Named {
6666
boolean canDisplay(Class<?> c);
6767

6868
/** Tests whether the display is capable of visualizing the given object. */
69-
boolean canDisplay(Object o);
69+
default boolean canDisplay(final Object o) {
70+
if (o == null) return false;
71+
return canDisplay(o.getClass());
72+
}
7073

7174
/**
7275
* Displays the given object in this display.
@@ -92,7 +95,9 @@ public interface Display<T> extends List<T>, RichPlugin, Named {
9295
* {@code DatasetView} that wraps that {@code Dataset}.
9396
* </p>
9497
*/
95-
boolean isDisplaying(Object o);
98+
default boolean isDisplaying(final Object o) {
99+
return contains(o);
100+
}
96101

97102
/** Updates and redraws the display onscreen. */
98103
void update();

0 commit comments

Comments
 (0)