Java 8 Supplier without double colon -
i unable create supplier without using :: notation. tutorials seem using :: method out.
function<string, object> beanfactory = m_context::getbean; function<void, ircpublic> ircpublicsupplier = -> (ircpublic) beanfactory.apply("developerpublicconnection"); ircpublicsupplier.apply(null);
how go turning line 2 single line statement create supplier, , being able use '.get()' . can use '.apply(null)' seems dirty.
thank you!
you inline:
supplier<ircpublic> ircpublicsupplier = () -> (ircpublic) beanfactory.apply("developerpublicconnection");
or wrap ircpublic
instance returned beanfactory
in method:
ircpublic getircpublic() { return (ircpublic) beanfactory.apply("developerpublicconnection"); }
and use ::
:
supplier<ircpublic> ircpublicsupplier = this::getircpublic;
this assumes above line in same class getircpublic
method defined.
Comments
Post a Comment