Skip to content

Commit 43b87e5

Browse files
committed
Contextual: push setContext default impl to iface
Thank you Java 8.
1 parent 10bbc86 commit 43b87e5

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

src/main/java/org/scijava/AbstractContextual.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,4 @@ public Context context() {
6262
public Context getContext() {
6363
return context;
6464
}
65-
66-
@Override
67-
public void setContext(final Context context) {
68-
context.inject(this);
69-
}
70-
7165
}

src/main/java/org/scijava/Contextual.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,14 @@ public interface Contextual {
6969
* </p>
7070
*
7171
* @see Context#inject(Object)
72-
* @see AbstractContextual for an example of how to implement this interface
7372
* @throws IllegalStateException If the object already has a context.
7473
* @throws IllegalArgumentException If the object has a required
7574
* {@link Service} parameter (see {@link Parameter#required()})
7675
* which is not available from the context.
7776
*/
78-
void setContext(Context context);
77+
default void setContext(final Context context) {
78+
context.inject(this);
79+
}
80+
7981

8082
}

0 commit comments

Comments
 (0)