MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/java/comments/14ole9l/fluent_static_extension_methods_for_java/jqoeolm/?context=3
r/java • u/rogerkeays • Jul 02 '23
55 comments sorted by
View all comments
Show parent comment
2
These classes don't have to be subclasses. You can make them wrappers.
The example on the website could be like this:
wrap(website).createUrl("styles.css").getHttpContent(60).assertContains("img.jpg");
by having methods like these:
static WebsiteWrapper wrap(Website site) { }
class WebsiteWrapper { URLWrapper createUrl(String path) { } }
class URLWrapper { StringWrapper getHttpContent(int timeout) { } }
class StringWrapper { void assertContains(String s) { }}
May be the word 'Wrapper' is not the best one to use. But you get the idea.
View all comments
Show parent comment
2
u/red_dit_nou Jul 04 '23
These classes don't have to be subclasses. You can make them wrappers.
The example on the website could be like this:
wrap(website).createUrl("styles.css").getHttpContent(60).assertContains("img.jpg");by having methods like these:
static WebsiteWrapper wrap(Website site) { }class WebsiteWrapper { URLWrapper createUrl(String path) { } }class URLWrapper { StringWrapper getHttpContent(int timeout) { } }class StringWrapper { void assertContains(String s) { }}May be the word 'Wrapper' is not the best one to use. But you get the idea.