Reputation: 641
I was looking into some tutorial and stumbled on this code:
public void run(String... args) throws Exception {
eventBus.on($("quotes"), receiver);
publisher.publishQuotes(NUMBER_OF_QUOTES);
}
This is the first time I see $("quotes")
in Java. I'd appreciate someone explaining to me what's going on there.
Here's the source:
Update:
This is not a question about $ as Java variable name. I know that it's a valid variable name. However, the format of $("something") looks JQuery-like; hence threw me off thinking that it's a special directive or something.
Upvotes: 3
Views: 1685
Reputation: 29680
it is just a call to the method called $
that is statically imported:
import static reactor.bus.selector.Selectors.$;
it is just a normal method with a strange name.
'$' is a valid character for identifiers according the Java Language Specification 3.8
The "Java letters" include uppercase and lowercase ASCII Latin letters A-Z (\u0041-\u005a), and a-z (\u0061-\u007a), and, for historical reasons, the ASCII underscore (_, or \u005f) and dollar sign ($, or \u0024). The $ sign should be used only in mechanically generated source code or, rarely, to access pre-existing names on legacy systems.
Upvotes: 4
Reputation: 201447
You have an import static reactor.bus.selector.Selectors.$;
From the documentation that is a short-hand alias for object(T)
which in turn creates a Selector
based on the given object.
Upvotes: 4