-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
20 additions
and
0 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
...mons-utils-parent/aksw-commons-utils/src/main/java/org/aksw/commons/util/obj/HasSelf.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package org.aksw.commons.util.obj; | ||
|
||
/** This interface is useful for builders of the form below, in order to hide | ||
* the uncheck cast warning of {@code return (X)this;}. | ||
* | ||
* <pre>{@code | ||
* interface MyBuilderMixin<X extends MyBuilderMixin<X>> extends HasSelf<X> { | ||
* default X someMethod() { | ||
* // Do something | ||
* return self(); | ||
* } | ||
* } | ||
* }</pre> | ||
*/ | ||
public interface HasSelf<T> { | ||
@SuppressWarnings("unchecked") | ||
default T self() { | ||
return (T)this; | ||
} | ||
} |