Created
October 21, 2016 22:44
-
-
Save swegner/8f80dee5f6901952d6a4ae946e61b142 to your computer and use it in GitHub Desktop.
Testing PipelineOptions builder syntax using self-referencing generics
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
import org.junit.Test; | |
import org.junit.runner.RunWith; | |
import org.junit.runners.JUnit4; | |
@RunWith(JUnit4.class) | |
public class GenericPipelineOptions { | |
public interface PipelineOptions<T extends PipelineOptions<T>> {} | |
public interface OptionsA<T extends OptionsA<T>> extends PipelineOptions<T> { | |
T setA1(); | |
T setA2(); | |
} | |
public interface OptionsB<T extends OptionsB<T>> extends PipelineOptions<T> { | |
T setB1(); | |
T setB2(); | |
} | |
public interface OptionsAB<T extends OptionsA<T> & OptionsB<T>> extends OptionsA<T>, OptionsB<T> {} | |
@Test | |
public void testBuilderSyntax() { | |
OptionsAB<?> opt = null; | |
opt | |
.setA1() | |
.setA2() | |
.setB1() | |
.setB2(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment