Skip to content

Instantly share code, notes, and snippets.

@sirolf2009
Last active October 5, 2018 10:14
Show Gist options
  • Save sirolf2009/df410b022c31b9d28ff18515dbf2d4d2 to your computer and use it in GitHub Desktop.
Save sirolf2009/df410b022c31b9d28ff18515dbf2d4d2 to your computer and use it in GitHub Desktop.
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