Last active
October 5, 2018 10:14
-
-
Save sirolf2009/df410b022c31b9d28ff18515dbf2d4d2 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
def Link getChain(Single<?> single) { | |
try { | |
val source = single.getClass().getDeclaredField("source") | |
source.setAccessible(true) | |
val sourceInstance = source.get(single) | |
if(sourceInstance instanceof Single) { | |
return new Link(Optional.ofNullable(getChain(sourceInstance)), single.toString()) | |
} else { | |
return new Link(Optional.empty(), single.toString()) | |
} | |
} catch(NoSuchFieldException e) { | |
return new Link(Optional.empty(), single.toString()) | |
} | |
} | |
@Data static class Link { | |
val Optional<Link> source | |
val String name | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment